Created
February 11, 2012 23:46
-
-
Save dshafik/1805158 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
<?php | |
$interval = DateInterval::createFromDateString("1 hour"); | |
$dateTime->add($interval); | |
echo $dateTime->format(DateTime::ATOM); // 2012-09-01T23:20:01+01:00 | |
?> |
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
<?php | |
$timeZone = new DateTimeZone("Europe/London"); | |
$dateTime->setTimezone($timeZone); | |
echo $dateTime->format(DateTime::ATOM); // 2012-09-01T22:20:01+01:00 | |
?> |
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
<?php | |
$interval = DateInterval::createFromDateString("1 year 3 months 8 days 2 hours"); | |
$dateTime->add($interval); | |
echo $dateTime->format(DateTime::ATOM); // 2013-12-10T01:20:01+00:00 | |
?> |
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
object(DateTime)#1 (3) { | |
["date"]=> string(19) "2012-09-01 16:20:01" | |
["timezone_type"]=> int(1) | |
["timezone"]=> string(6) "-05:00" | |
} |
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
<?php | |
echo fuzzyDate("2011-09-16T11:38:23-05:00"); // Last Friday at 11:38am | |
echo fuzzyDate(date(DATE_ATOM)); // Today at 11:18am | |
echo fuzzyDate("2011-09-21T00:00:00-05:00"); // Tomorrow at midnight | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment