|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-29 09:12 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2016-03-29 09:12 UTC] requinix@php.net
[2016-03-29 09:33 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 12:00:01 2026 UTC |
Description: ------------ i use php library "Carbon/Carbon" witch use DateTime directly and when i add one day to this exact day "2016-03-20" with timezone of "Asia/Tehran" it give one extra hour but when i add two day it works just fine. Test script: --------------- $timezone = new DateTimeZone('Asia/Tehran'); $dayStart = new DateTime('2016-03-20 00:00:00.000000', $timezone); $dayOne = (new DateTime('2016-03-20 00:00:00.000000', $timezone))->modify('1 day'); $dayTwo = (new DateTime('2016-03-20 00:00:00.000000', $timezone))->modify('2 day'); echo json_encode([ '$dayStart' => $dayStart, '$dayOne' => $dayOne, 'diff of $dayOne' => $dayStart->diff($dayOne,true), '$dayTwo' => $dayTwo, 'diff of $dayTwo' => $dayStart->diff($dayTwo,true), ]); die; Expected result: ---------------- { "$dayStart": { "date": "2016-03-20 00:00:00.000000", "timezone_type": 3, "timezone": "Asia\/Tehran" }, "$dayOne": { "date": "2016-03-21 00:00:00.000000", "timezone_type": 3, "timezone": "Asia\/Tehran" }, "diff of $dayOne": { "y": 0, "m": 0, "d": 1, "h": 0, "i": 0, "s": 0, "weekday": 0, "weekday_behavior": 0, "first_last_day_of": 0, "invert": 0, "days": 1, "special_type": 0, "special_amount": 0, "have_weekday_relative": 0, "have_special_relative": 0 }, "$dayTwo": { "date": "2016-03-22 00:00:00.000000", "timezone_type": 3, "timezone": "Asia\/Tehran" }, "diff of $dayTwo": { "y": 0, "m": 0, "d": 2, "h": 0, "i": 0, "s": 0, "weekday": 0, "weekday_behavior": 0, "first_last_day_of": 0, "invert": 0, "days": 2, "special_type": 0, "special_amount": 0, "have_weekday_relative": 0, "have_special_relative": 0 } } Actual result: -------------- { "$dayStart": { "date": "2016-03-20 00:00:00.000000", "timezone_type": 3, "timezone": "Asia\/Tehran" }, "$dayOne": { "date": "2016-03-21 01:00:00.000000", "timezone_type": 3, "timezone": "Asia\/Tehran" }, "diff of $dayOne": { "y": 0, "m": 0, "d": 1, "h": 1, "i": 0, "s": 0, "weekday": 0, "weekday_behavior": 0, "first_last_day_of": 0, "invert": 0, "days": 1, "special_type": 0, "special_amount": 0, "have_weekday_relative": 0, "have_special_relative": 0 }, "$dayTwo": { "date": "2016-03-22 00:00:00.000000", "timezone_type": 3, "timezone": "Asia\/Tehran" }, "diff of $dayTwo": { "y": 0, "m": 0, "d": 2, "h": 0, "i": 0, "s": 0, "weekday": 0, "weekday_behavior": 0, "first_last_day_of": 0, "invert": 0, "days": 2, "special_type": 0, "special_amount": 0, "have_weekday_relative": 0, "have_special_relative": 0 } }