Edit report at https://bugs.php.net/bug.php?id=60176&edit=1

 ID:                 60176
 Updated by:         f...@php.net
 Reported by:        sombra2eternity at gmail dot com
 Summary:            date + strtotime fails to calculate date
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Date/time related
 Operating System:   Ubuntu
 PHP Version:        5.4
 Block user comment: N
 Private report:     N

 New Comment:

We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.

You do realize that there are indeed 24h between 2011-10-30 00:00:00 and 
2011-10-30 23:00:00, right?

This is when DST was adjusted.

Try your code with 2011-10-31 and you'll see 2011-11-01 as a result of adding 
24h.


Previous Comments:
------------------------------------------------------------------------
[2011-10-31 14:37:58] sombra2eternity at gmail dot com

I just compiled: php5.4-201110311230

-------------------
desktop7@desktop7-desktop:~/php5.4-201110311230/sapi/cli$ ./php -v
PHP 5.4.0RC1-dev (cli) (built: Oct 31 2011 15:21:08) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies
-------------------

desktop7@desktop7-desktop:~/php5.4-201110311230/sapi/cli$ ./php 
/var/www/strto.php
2011-10-30

CONTENT OF STRTO.PHP:
<?php
date_default_timezone_set('Europe/Madrid');
echo date('Y-m-d',strtotime('2011-10-30')+86400);
?>

Thanks for helping me

------------------------------------------------------------------------
[2011-10-31 14:01:32] f...@php.net

I can't reproduce this with PHP_5_3 HEAD.

Could you please check that your "date.timezone" is set correctly in your 
php.ini?

It could help to compare "Y-m-d H:i:s" output.

------------------------------------------------------------------------
[2011-10-31 00:20:04] sombra2eternity at gmail dot com

Description:
------------
Dont know if corrected in new versions but I cant actually upgrade so I write 
it here anyway to be sure its reported.

Strtotime/date fails to get the date in a simple test.

I think I found a bug:

echo date("Y-m-d",strtotime('2011-10-30')+86400);
//returns 2011-10-30 and should return 2011-10-31

desktop7@desktop7-desktop:~$ php -v
PHP 5.3.5-1ubuntu7.3 with Suhosin-Patch (cli) (built: Oct 13 2011 21:56:07) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Test script:
---------------
echo date("Y-m-d",strtotime('2011-10-30')+86400);

Expected result:
----------------
2011-10-31

Actual result:
--------------
2011-10-30


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60176&edit=1

Reply via email to