|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53650 Fail on strtotime('last day of this year')
Submitted: 2011-01-04 18:34 UTC Modified: 2022-05-13 13:34 UTC
Avg. Score:3.3 ± 1.2
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: tripollite at gmail dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: 5.3.4 OS: Debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-01-04 18:34 UTC] tripollite at gmail dot com
date('d/m/Y',strtotime('last day of this year', mktime(1,1,1,1,1,2011)));

expected : 31/12/2011
get : 31/01/2011

Test script:
echo date('d/m/Y',strtotime('last day of this year', mktime(1,1,1,1,1,2011)));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-04 19:23 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: derick
 [2011-01-04 19:23 UTC]
Works for me, could you run the following script please:

echo date_default_timezone_get(), "\n";
$ts = mktime(1,1,1,1,1,2011);
echo $ts, ': ', date('Y-m-d H:i:s e', $ts), "\n";
$newTs = strtotime('last day of this year', $ts );
echo $newTs, ': ', date('Y-m-d H:i:s e', $newTs), "\n";
 [2011-01-04 19:31 UTC] tripollite at gmail dot com
-Status: Feedback +Status: Assigned
 [2011-01-04 19:31 UTC] tripollite at gmail dot com
1293840061: 2011-01-01 01:01:01 Europe/Paris
1296432061: 2011-01-31 01:01:01 Europe/Paris
 [2011-01-04 19:44 UTC]
All right. Will check.
 [2011-01-04 19:48 UTC]
-Type: Bug +Type: Feature/Change Request -Package: Unknown/Other Function +Package: Date/time related
 [2011-01-04 19:48 UTC]
Ah, I see it. "last day of" is only implemented for "month", not "year". Obviously, the first and last days of a year are always going to be the same: Jan 1st, and Dec 31st. I'm leaving this as a Feature Request.
 [2015-03-06 11:41 UTC] emshidiq at gmail dot com
you can use "last day of december" :D
 [2016-01-11 06:12 UTC] ryosvashek at gmail dot com
Just hit the same snatch.

Had to go with date('last day of December '.date('Y'))

Will love to have this in the feature.
 [2017-10-24 07:55 UTC]
-Status: Assigned +Status: Open -Assigned To: derick +Assigned To:
 [2022-05-13 13:34 UTC]
-Status: Open +Status: Wont fix
 [2022-05-13 13:34 UTC]

I'm not going to add this as it increases parser complexity, with a simple workaround available. You can either use "31 december this year", or "1 january this year", or "31 december", or "1 january" to achieve the same.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jun 29 17:04:06 2022 UTC