Technology Programming

When Is Thanksgiving?

Although there is no specific PHP function to give you the date of Thanksgiving in any given year, we know that in the USA it always falls on the forth Thursday in November. Using this information we can calculate the actual date using the script below:

<?php//This gets today's date$date =time () ; //This makes the current year a variable$year = date('Y', $date) ; //Here we generate the first day of November $first_day = mktime(0,0,0,11, 1, $year) ; //We determine what day of the week the first falls on $day_of_week = date('D', $first_day) ; //Based upon this, we add the appropriate number of days to get to the forth Thursday of the month switch($day_of_week){case "Sun": $add = 25; break; case "Mon": $add = 24; break;case "Tue": $add = 23; break;case "Wed": $add = 22; break;case "Thu": $add = 21; break;case "Fri": $add = 27; break;case "Sat": $add = 26; break;} $Thanks = 1 + $add; echo "This year, $year, Thanksgiving Day falls on 11/$Thanks."; ?>

If you want to calculate when Thanksgiving falls for any other year you can modify the $date =time () ; line to use the mktime () function to generate a date in any year you wish.

Related posts "Technology : Programming"

The Importance Of Having a WordPress Business Theme

Programming

Website Design Is Necessary For Your Website

Programming

The Most effective On line Paid Survey Evaluation

Programming

Adelaide SEO - Links And Keywords, How Should They Be Used

Programming

C Programming Compilers for Microcontrollers

Programming

How Should A DJ Make Music Logo That Is Distinct And Cool?

Programming

Call to Action Concepts for Small Businesses

Programming

Microsoft Access Databases in Office 365

Programming

Why web design is crucial for producing world class websites

Programming

Leave a Comment