Just wanted to store some code I use a lot and am tired of looking up 😉
In some of the scripts I work on, I create a field for a timestamp. For that field I insert the PHP value: time()
When recalling that value, it's just an ugly looking UNIX timestamp, so to format it to something nice, I do the following: (as posted on the PHP manual)
<?php
/*
Assuming the UNIX timestap was for : March 10th, 2001, 5:16:18 pm
and you already did a mysql query, and fetch_array
and the name of the field for timestamp, is 'timestamp'
*/
$today = date("F j, Y, g:i a", $row['timestamp']);
// March 10, 2001, 5:16 pm
$today = date("m.d.y", $row['timestamp']);
// 03.10.01
$today = date("Ymd", $row['timestamp']);
// 20010310
$today = date('\i\t \i\s \t\h\e jS \d\a\y.', $row['timestamp']);
// It is the 10th day.
$today = date("D M j G:i:s T Y", $row['timestamp']);
// Sat Mar 10 15:16:08 MST 2001
?>