PHP Blog… finally
Tuesday, December 21st, 2004 at 9:22 pmMy blog is now fully PHPed. I am using a DATETIME type to store the dates it’s an official type instead of that hack I threw together that was a BIGINT. I now convert the DATETIME into a Unix timestamp so that I can re-format it as a string.
/*converts the DATETIME to a Unix timestamp*/
function toUnixDate($timestamp)
{
//echo "<p class=\"debug\">$timestamp</p>";
$ts_year = substr($timestamp,0,4);
$ts_month = substr($timestamp,5,2);
$ts_day = substr($timestamp,8,2);
$ts_hour = substr($timestamp,11,2);
$ts_minute = substr($timestamp,14,2);
$ts_second = substr($timestamp,17,2);
return mktime($ts_hour,$ts_minute,$ts_second,$ts_month,$ts_day,$ts_year);
}
UPDATE: I later pulled the value directly from the database as a Unix timestamp using a MySQL function for efficiency but I don’t think it is standard SQL.