...

View Full Version : Convert date without a timestamp



[m] at
06-09-2005, 08:49 PM
I'm trying to convert a date from 0000-00-00 format to something a little nicer to read. However, I can't use the strtotime function because the year is 5 years prior to the Unix epoch. Does anyone know of a way that I can convert a date's format without a timestamp?

[m] at
06-09-2005, 09:18 PM
Got tired of waiting and wrote my own function.



function date_convert(&$date) {
$year = substr($date, 0, 4);
$month = substr($date, strlen($year) + 1, 2);
$day = substr($date, strlen($year) + 4, 2);

switch ($month) {
case "01": $month = "Jan"; break;
case "02": $month = "Feb"; break;
case "03": $month = "Mar"; break;
case "04": $month = "Apr"; break;
case "05": $month = "May"; break;
case "06": $month = "Jun"; break;
case "07": $month = "Jul"; break;
case "08": $month = "Aug"; break;
case "09": $month = "Sep"; break;
case "10": $month = "Oct"; break;
case "11": $month = "Nov"; break;
case "12": $month = "Dec"; break;
}
$date = "$month $day, $year";
return $date;
}

delinear
06-09-2005, 10:10 PM
I'm guessing you're using a Windows server? Most *nix servers support negative timestamps so you can take the date back to circa 1901.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum