Unix Timestamp Conversion

Description: Examples of converting UNIX timestamps to more useful formats.

<?PHP
 
// produces a timestamp that looks like "YYYY-MM-DD 24:00:00":
$formated_datetime = DATE("Y-m-d H:i:s");
 
// takes $formated_datetime and converts to "UNIX timestamp":
$unix_timestamp = STRTOTIME($formated_datetime);
 
// converts $unix_timestamp to "normal" formated_datetime:
$formated_datetime = DATE("Y-m-d H:i:s",$unix_timestamp);
 
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.