RE: [PHP] strtotime()
| From: | Jennifer Goodie | Date: | Wed, 13 Aug 2003 19:30:36 +0000 |
| Subject: | RE: [PHP] strtotime() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159478@lists.php.net to get a copy of this message | ||
> > > strtotime( '+1 month', mktime( 0, 0, 0, 1, 1, 2003 ));
> > > I get back the timestamp for 1/31/2003 and not 2/1/2003.
> > Are you sure?
>
> Yeah, but I missed something in my above example. If I did this:
>
> strtotime( '+1 month GMT', mktime( 0, 0, 0, 1, 1, 2003 ));
>
> It came back with 1/31/2003 and not 2/1/2003. Removing the GMT
> made it work.
Are you somewhere behind GMT? I get an hour shift when using GMT that puts
me in the previous day. I'm GMT -8. I can't think right now, but for some
reason it seems like it's shifting in the wrong direction or at least the
opposite of what I'd expect. I guess it is subtracting my 8 hours and then
shifting, making it 16:00 of the previous day. It seems like it should add
8 hours since GMT is 8 ahead of me. This is making my head hurt, maybe
someone else can make it make sense.
# php
<?php
$ts = mktime( 0, 0, 0, 1, 1, 2003 );
echo date ("Y-m-d H:i:s",$ts)."\n";
$ts2 = strtotime('+1 month GMT', $ts);
echo date ("Y-m-d H:i:s",$ts2)."\n";
$ts3 = strtotime('+1 month', $ts);
echo date ("Y-m-d H:i:s",$ts3)."\n";
?>
X-Powered-By: PHP/4.2.3
Content-type: text/html
2003-01-01 00:00:00
2003-01-31 16:00:00
2003-02-01 00:00:00