NYCPHP Meetup

NYPHP.org

[nycphp-talk] Date switching back and forth

Jonathan hendler at simmons.edu
Sat Oct 1 09:39:39 EDT 2005


There is an error in your code.
You will always have the correctly adjusted hour because of

 date("g:i:s a", 
time() + $timeadjust) 


But your date will be wrong for 4 hours every day because of

echo date("l") . "<br>" . date("F jS, Y")


You need to add your time adjust to each of those dates.
Try
$adjusted_time = time() + $timeadjust;

echo date("l",$adjusted_time) . "<br>" . date("F jS, Y",$adjusted_time);
date("g:i:s a", $adjusted_time) ; 



harvey wrote:

>How is this possible? I have a site hosted at Yahoo and am using the 
>following code to display the date/time at the top of the page. Works 
>fine, except-- every once in a while, the date is one full day off. 
>For example, on the 28th of this month at about 10pm, the page said 
>it was the 29th at 10pm. Later on, it was fine and said the right 
>date. Yahoo, of course, says it's not them, but what else could it 
>be? Thanks in advance.
>
>$hourdiff = "-4";
>$timeadjust = ($hourdiff * 60 * 60);
>echo date("l") . "<br>" . date("F jS, Y") . "<br>" . date("g:i:s a", 
>time() + $timeadjust) . "&nbsp;NYC";
>
>_______________________________________________
>New York PHP Talk Mailing List
>AMP Technology
>Supporting Apache, MySQL and PHP
>http://lists.nyphp.org/mailman/listinfo/talk
>http://www.nyphp.org
>  
>




More information about the talk mailing list