Skip to content

Instantly share code, notes, and snippets.

@sp3c73r2038
Created January 13, 2011 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sp3c73r2038/777381 to your computer and use it in GitHub Desktop.
Save sp3c73r2038/777381 to your computer and use it in GitHub Desktop.
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