|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-05-28 18:14 UTC] dr dot hab dot freek at gmail dot com
Description: ------------ So - we see in manual strtotime() should working great with all formats from http://www.php.net/manual/en/datetime.formats.php so if we run: date('Y-m-d H:i:s', strtotime('2008')); //return current date with the wrong time - 2014-05-28 20:08:00 So we can't use strtotime(date('Y')) so we should add month: strtotime(date('Y-m')) - then it works. Test script: --------------- date('Y-m-d H:i:s', strtotime('2008')); Expected result: ---------------- 2008-01-01 00:00:00 Actual result: -------------- 2014-05-28 20:08:00 //invalid date with modified time PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 18:00:02 2026 UTC |
> strtotime('1999') will give you the kind of result you're looking for. By that I mean it gives you a timestamp from that year. It won't be for midnight on January 1st but instead copies the current time's components.