Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
php time and date convertion
<?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
You can’t perform that action at this time.