php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24927 strtotime 'next' failure
Submitted: 2003-08-03 17:49 UTC Modified: 2003-08-03 17:58 UTC
From: joergleu at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.3RC2 OS: Windows XP, Linux Suse 8.2
Private report: No CVE-ID: None
 [2003-08-03 17:49 UTC] joergleu at hotmail dot com
Description:
------------
I found an failure in the strtotime function. When I used the function strtotime ('next hour/day/week/...') then the result I expected was wrong (The result is one greater).
The similiar function call strtotime('last ...') works correctly.
In PHP Version 4.2.2 (Linux) works the function correctly.

Reproduce code:
---------------
$now = mktime(12,0,0,8,1,2003);
print $now . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', $now);
print strtotime('last hour', $now) . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', strtotime('last hour', $now));
print strtotime('next hour', $now) . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', strtotime('next hour', $now));
print strtotime('last day', $now) . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', strtotime('last day', $now));
print strtotime('next day', $now) . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', strtotime('next day', $now));
print strtotime('last week', $now) . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', strtotime('last week', $now));
print strtotime('next week', $now) . ', ' . strftime('%A %d. %B %Y - %H:%M:%S', strtotime('next week', $now));

Expected result:
----------------
X-Powered-By: PHP/4.2.2
1059732000, Friday 01. August 2003 - 12:00:00
1059728400, Friday 01. August 2003 - 11:00:00
1059735600, Friday 01. August 2003 - 13:00:00
1059645600, Thursday 31. July 2003 - 12:00:00
1059818400, Saturday 02. August 2003 - 12:00:00
1059127200, Friday 25. July 2003 - 12:00:00
1060336800, Friday 08. August 2003 - 12:00:00

Actual result:
--------------
X-Powered-By: PHP/4.3.3RC2-dev
1059732000, Friday 01. August 2003 - 12:00:00
1059728400, Friday 01. August 2003 - 11:00:00
1059739200, Friday 01. August 2003 - 14:00:00
1059645600, Thursday 31. July 2003 - 12:00:00
1059904800, Sunday 03. August 2003 - 12:00:00
1059127200, Friday 25. July 2003 - 12:00:00
1060941600, Friday 15. August 2003 - 12:00:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-03 17:58 UTC] iliaa@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

Duplicate of bug #18670, #22814
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 09:01:33 2024 UTC