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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fengzbao at qq dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 01:00:01 2026 UTC