Bug #55015 [Opn]: strToTime calculates wrong date

2011-07-06 Thread cp at ltur dot de
Edit report at https://bugs.php.net/bug.php?id=55015edit=1

 ID: 55015
 User updated by:cp at ltur dot de
 Reported by:cp at ltur dot de
 Summary:strToTime calculates wrong date
 Status: Open
 Type:   Bug
 Package:Date/time related
 Operating System:   Linux
 PHP Version:5.3.6
 Block user comment: N
 Private report: N

 New Comment:

Hi,

i applied the patch from lonny and it works for me :-)

php  date_default_timezone_set('Europe/Berlin');
php  echo date('Ymd N', strToTime('next month next Monday', 
mktime(0,0,0,6,9,2011)));

// prints
20110711 1

Will somebody commit his patch?

kind regards
.cp


Previous Comments:

[2011-07-06 02:10:07] lonnyk at gmail dot com

The problem is that the relative weekday was calculated before the relative 
month/year. I attached a batch and a test to change the order of the 
calculation.


[2011-07-01 04:52:27] lonnyk at gmail dot com

I also found that if you are using this code and the next Monday is in the next 
month then the month will advance two months. I set the date to 20110630 and 
ran 
the exact same test script:

lonny@lonnydev:~/php/php-src-5.3$ sudo date -s 30 JUN 2011 10:00:00
Thu Jun 30 10:00:00 EDT 2011
lonny@lonnydev:~/php/php-src-5.3$ php ~/test.php 
20110804 4


[2011-06-09 14:13:00] cp at ltur dot de

Description:

Hi,

strToTime calculates a Wednesday when i asked for a Monday.

php 5.3.6
Configure Command =  './configure'  '--disable-cgi' '--with-libedit'
PHP API = 20090626
PHP Extension = 20090626
Zend Extension = 220090626
Zend Extension Build = API220090626,NTS
PHP Extension Build = API20090626,NTS


Test script:
---
// today Y-m-d 2011-06-09 
date_default_timezone_set('Europe/Berlin');
echo date('Ymd N', strToTime('next month next Monday'));



Expected result:

20110711 1

Actual result:
--
20110713 3






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


Bug #55015 [Com]: strToTime calculates wrong date

2011-07-06 Thread cp at ltur dot de
Edit report at https://bugs.php.net/bug.php?id=55015edit=1

 ID: 55015
 Comment by: cp at ltur dot de
 Reported by:cp at ltur dot de
 Summary:strToTime calculates wrong date
 Status: Wont fix
 Type:   Bug
 Package:Date/time related
 Operating System:   Linux
 PHP Version:5.3.6
 Block user comment: N
 Private report: N

 New Comment:

Hi Derick,

 We can't just randomly change the order because other people may rely on it.

I understand this, but it is still a bug. It should be mentioned in the 
strToTime() documentation along with the workaround you posted, so people use 
the function with care.

kind regards
.cp


Previous Comments:

[2011-07-06 05:01:13] der...@php.net

We can't just randomly change the order because other people may rely on it. 
What you want to do is really this:

$date = date_create(2011-06-09 00:00:00)-modify(next month)-modify(next 
monday);


[2011-07-06 03:41:37] cp at ltur dot de

Hi,

i applied the patch from lonny and it works for me :-)

php  date_default_timezone_set('Europe/Berlin');
php  echo date('Ymd N', strToTime('next month next Monday', 
mktime(0,0,0,6,9,2011)));

// prints
20110711 1

Will somebody commit his patch?

kind regards
.cp


[2011-07-06 02:10:07] lonnyk at gmail dot com

The problem is that the relative weekday was calculated before the relative 
month/year. I attached a batch and a test to change the order of the 
calculation.


[2011-07-01 04:52:27] lonnyk at gmail dot com

I also found that if you are using this code and the next Monday is in the next 
month then the month will advance two months. I set the date to 20110630 and 
ran 
the exact same test script:

lonny@lonnydev:~/php/php-src-5.3$ sudo date -s 30 JUN 2011 10:00:00
Thu Jun 30 10:00:00 EDT 2011
lonny@lonnydev:~/php/php-src-5.3$ php ~/test.php 
20110804 4


[2011-06-09 14:13:00] cp at ltur dot de

Description:

Hi,

strToTime calculates a Wednesday when i asked for a Monday.

php 5.3.6
Configure Command =  './configure'  '--disable-cgi' '--with-libedit'
PHP API = 20090626
PHP Extension = 20090626
Zend Extension = 220090626
Zend Extension Build = API220090626,NTS
PHP Extension Build = API20090626,NTS


Test script:
---
// today Y-m-d 2011-06-09 
date_default_timezone_set('Europe/Berlin');
echo date('Ymd N', strToTime('next month next Monday'));



Expected result:

20110711 1

Actual result:
--
20110713 3






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


[PHP-BUG] Bug #55015 [NEW]: strToTime calculates wrong date

2011-06-09 Thread cp at ltur dot de
From: 
Operating system: Linux
PHP version:  5.3.6
Package:  Date/time related
Bug Type: Bug
Bug description:strToTime calculates wrong date

Description:

Hi,



strToTime calculates a Wednesday when i asked for a Monday.



php 5.3.6

Configure Command =  './configure'  '--disable-cgi' '--with-libedit'

PHP API = 20090626

PHP Extension = 20090626

Zend Extension = 220090626

Zend Extension Build = API220090626,NTS

PHP Extension Build = API20090626,NTS



Test script:
---
// today Y-m-d 2011-06-09 

date_default_timezone_set('Europe/Berlin');

echo date('Ymd N', strToTime('next month next Monday'));





Expected result:

20110711 1

Actual result:
--
20110713 3

-- 
Edit bug report at http://bugs.php.net/bug.php?id=55015edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=55015r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=55015r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=55015r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=55015r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=55015r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=55015r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=55015r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=55015r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=55015r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=55015r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=55015r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=55015r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=55015r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=55015r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=55015r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=55015r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=55015r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=55015r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=55015r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=55015r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=55015r=mysqlcfg