php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70691 strtotime to timestamp issue
Submitted: 2015-10-12 03:05 UTC Modified: 2015-10-12 03:29 UTC
From: fengzbao at qq dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.4.45 OS: centos 6.5 32
Private report: No CVE-ID: None
 [2015-10-12 03:05 UTC] fengzbao at qq dot com
Description:
------------
strtotime transfet string to timestamp issue some problem.

echo date('Y-m-d', strtotime('151011'));

we see:
2015-10-12

this is wrong.

and you can solve this case like this:
echo date('Y-m-d', '20' . strtotime('151011'));

Test script:
---------------
echo date('Y-m-d', strtotime('151011'));

Expected result:
----------------
2015-10-12

Actual result:
--------------
2015-10-11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-12 03:06 UTC] fengzbao at qq dot com
-Operating System: +Operating System: centos 6.5 32
 [2015-10-12 03:06 UTC] fengzbao at qq dot com
add os information
 [2015-10-12 03:29 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *Database Functions +Package: Date/time related
 [2015-10-12 03:29 UTC] requinix@php.net
It's a lot more obvious what is happening if you output the full date and time.
https://3v4l.org/TTj3g

And as you can see, your "solution" is very much incorrect.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 13:01:36 2024 UTC