Created
February 9, 2015 03:22
-
-
Save s-shin/24b07ad74a6c2c8dd70d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> $dt1 = new DateTime() | |
| => <DateTime #000000007766f6860000000009e51d7d> { | |
| date: "2015-02-09 12:13:50", | |
| timezone_type: 3, | |
| timezone: "Asia\/Tokyo" | |
| } | |
| >>> $dt2 = new DateTime('@'.$dt1->getTimestamp()) | |
| => <DateTime #000000007766f6810000000009e51d7d> { | |
| date: "2015-02-09 03:13:50", | |
| timezone_type: 1, | |
| timezone: "+00:00" | |
| } | |
| >>> $ddt = $dt1->diff($dt2) | |
| => <DateInterval #000000007766f6840000000009e51ccd> { | |
| y: 0, | |
| m: 0, | |
| d: 0, | |
| h: 0, | |
| i: 0, | |
| s: 0, | |
| weekday: 0, | |
| weekday_behavior: 0, | |
| first_last_day_of: 0, | |
| invert: 0, | |
| days: 0, | |
| special_type: 0, | |
| special_amount: 0, | |
| have_weekday_relative: 0, | |
| have_special_relative: 0 | |
| } | |
| >>> $dt1->format('Y-m-d H:i:s') | |
| => "2015-02-09 12:13:50" | |
| >>> $dt2->format('Y-m-d H:i:s') | |
| => "2015-02-09 03:13:50" | |
| >>> $dt2->setTimezone(new DateTimeZone(date_default_timezone_get())); | |
| => <DateTime #000000007766f6810000000009e51d7d> { | |
| date: "2015-02-09 12:13:50", | |
| timezone_type: 3, | |
| timezone: "Asia\/Tokyo" | |
| } | |
| >>> $dt2->format('Y-m-d H:i:s') | |
| => "2015-02-09 12:13:50" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment