$time) { $next_spring = $nearest_spring_ahead; } else { $next_spring = strtotime("Second Sunday March 0 +1 year", $time ); } if (strtotime("+1 day", $nearest_fall_back) > $time) { $next_fall = $nearest_fall_back; } else { $next_fall = strtotime("First Sunday November 0 +1 year", $time); } // if next upcoming dst is spring set show_spring to true otherwise false if ($next_fall > $next_spring) $show_spring = 1; else $show_spring = 0; // Will return the number of days between the two dates passed in function count_days( $a, $b ) { // First we need to break these dates into their constituent parts: $gd_a = getdate( $a ); $gd_b = getdate( $b ); // Now recreate these timestamps, based upon noon on each day // The specific time doesn't matter but it must be the same each day $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] ); $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] ); // Subtract these two numbers and divide by the number of seconds in a // day. Round the result since crossing over a daylight savings time // barrier will cause this time to be off by an hour or two. return round( abs( $a_new - $b_new ) / 86400 ); } // assign variables to be used by html based on whether this is a spring or fall page if ($show_spring) { $season = "spring"; $to_next = count_days( $next_spring, $time ); $to_previous = count_days( $nearest_fall_back, $time ); $associatedword = "forward"; $justpast = "fell back"; } else { $season = "fall"; $to_next = count_days( $next_fall, $time ); $to_previous = count_days( $nearest_spring_ahead, $time ); $associatedword = "back"; $justpast = "sprung forward"; } ?> When is Daylight Savings Time?
1) { ?>
IN
DAYS

IN
1 DAY


TODAY
You fell back 1 Day Ago.
= 1) { ?>
You fell back Days Ago.