Created
January 13, 2011 04:22
-
-
Save sp3c73r2038/777381 to your computer and use it in GitHub Desktop.
php time and date convertion
This file contains 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 | |
/* from unix timestamp to date */ | |
$time = time(); | |
echo date("Y-m-d H:i:s", $time),"\n"; | |
/* from date string to timestamp */ | |
$date = '2011-01-01 00:00:00'; | |
echo strtotime($date),"\n"; | |
/* make unix timestamp from datestring - another way */ | |
$date = '2011-01-01'; | |
list($year, $month, $day) = explode("-", $date); | |
echo mktime(0, 0, 0, $month, $day, $year),"\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment