|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-05-18 11:03 UTC] shivamkss at gmail dot com
Description:
------------
date function is returning 2017-07 while adding 1 month to "2017-05-31 09:00:00". My time zone is Asia/Calcutta.
Test script:
---------------
$date = "2017-05-31 09:00:00";
return date("Y-m",strtotime("+1 month", strtotime($date)));
Expected result:
----------------
It should return 2017-06
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
You don't need custom logic for this at all. You can just do: <?php $a = new DateTimeImmutable("2017-05-31 09:00:00"); $b = $a->modify("first day of next month"); echo $b->format("Y-m");