NYCPHP Meetup

NYPHP.org

[nycphp-talk] Date switching back and forth

Brian O'Connor gatzby3jr at gmail.com
Sat Oct 1 12:09:04 EDT 2005


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> 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://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20051001/b2b19ac9/attachment.html>


More information about the talk mailing list