php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53740 DateTime, create_date, strtotime - wrong result on realtive date time string
Submitted: 2011-01-13 17:10 UTC Modified: 2011-01-14 12:11 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: metwo at gmx dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.5 OS: Linux 2.6.36.3 x86_64
Private report: No CVE-ID: None
 [2011-01-13 17:10 UTC] metwo at gmx dot net
Description:
------------
parsing of "midnight first day last month" returns a wrong result in php 5.3.5 (worked correct in php 5.3.2)

Test script:
---------------
<?php

print_r(date_create('midnight first day last month'));

print date('Y-m-d H:i:s', strtotime('midnight first day last month'));

Expected result:
----------------
DateTime Object
(
    [date] => 2010-12-01 00:00:00
    [timezone_type] => 3
    [timezone] => Europe/Berlin
)

2010-12-01 00:00:00

Actual result:
--------------
DateTime Object
(
    [date] => 2010-12-14 00:00:00
    [timezone_type] => 3
    [timezone] => Europe/Berlin
)

2010-12-14 00:00:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-13 17:12 UTC] metwo at gmx dot net
Expected and actual result relative to current date/time - 2011-01-13 17:12
 [2011-01-14 12:11 UTC] derick@php.net
-Status: Open +Status: Bogus
 [2011-01-14 12:11 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This was broken in < 5.3.3, you need to use the "first day of" phrase (and not use "first day"). "first day" means the same as "next day" (and always has).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 13:01:29 2024 UTC