Home >> Snippet List >> Snippet

Name
UNIX Timestamp conversion
Description
Examples of converting UNIX timestamps to more useful formats
PHP Snippet
<?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);   
 
?>