NYCPHP Meetup

NYPHP.org

[nycphp-talk] Date switching back and forth

Jonathan hendler at simmons.edu
Sat Oct 1 18:47:20 EDT 2005


strtotime() is also fun!

Brian O'Connor wrote:

> I prefer to use mktime for converting dates, but I guess that's just a 
> preference.
>
> $dateConversion = date('Y-m-d', mktime(date('H')-4, date('i'), 
> date('s'), date('m'), date('d'), date('Y')));
>
> On 10/1/05, *harvey* < list at harveyk.com <mailto:list at harveyk.com>> wrote:
>
>     Of course, not sure why I didn't see that.
>     Thanks a lot!
>
>
>     At 09:39 AM 10/1/2005, Jonathan wrote:
>
>     >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
>     > >
>     > >
>     >
>     >_______________________________________________
>     >New York PHP Talk Mailing List
>     >AMP Technology
>     >Supporting Apache, MySQL and PHP
>     >http://lists.nyphp.org/mailman/listinfo/talk
>     <http://lists.nyphp.org/mailman/listinfo/talk>
>     >http://www.nyphp.org
>
>     _______________________________________________
>     New York PHP Talk Mailing List
>     AMP Technology
>     Supporting Apache, MySQL and PHP
>     http://lists.nyphp.org/mailman/listinfo/talk
>     http://www.nyphp.org
>
>
>
>
> -- 
> Brian O'Connor
>
>------------------------------------------------------------------------
>
>_______________________________________________
>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