Forum Moderators: coopster
function showdate($dated) // for straight timestamp 14
{
$hour = substr($dated,8,2);
$minute = substr($dated,10,2);
$second = substr($dated,12,2);
$month = substr($dated,4,2);
$day = substr($dated,6,2);
$year = substr($dated,0,4);
$mktime = mktime($hour, $minute, $second, $month, $day, $year);
$formatted = date("F j, Y g:i a",$mktime);
return $formatted;
}
function showdate_II($dated)// for the DATETIME format
{
$hour = substr($dated,11,2);
$minute = substr($dated,14,2);
$second = substr($dated,17,2);
$month = substr($dated,5,2);
$day = substr($dated,8,2);
$year = substr($dated,0,4);
$mktime = mktime($hour, $minute, $second, $month, $day, $year);
$formatted = date("F j, Y g:i a",$mktime);
return $formatted;
}
A traditional Unix timestamp, which is what PHP's date() depends on to work properly, is defined as "the number of seconds since January 1 1970 00:00:00 GMT", and is typically not very human-readable.
MySQL TIMESTAMP fields vary from release to release, it seems (this doc probably tells you the most about it [dev.mysql.com]).
Try converting the MySQL TIMESTAMP into a Unix timestamp and then making it human-readable:
$thistime=date("Y-m-d H:i:s", [url=http://www.php.net/manual/en/function.strtotime.php]strtotime[/url]($row["timestamp"])); or something similar.