I am having a bit of a problem with formatting dates.
My first problem is that although my db has a value of: 2003-07-14
Once I apply my FixDate fix it returns a date like this: 14 Jul 2000
I can't understand why this is happening. Any ideas?
Here is the code I am using:
//Function to fix mySQL date format
function fixDate($val)
{
//Split up in to components
$arr = explode(" ",$val);
$datearr = explode("-", $arr[0]);
//Create timestamp with mktime(), format it with date()
return date("d M Y", mktime(0,0,0, $datearr[1], $datearr[2], $datearr[3]));
}
My second problem occurs when I try to return this value in an input field, where only the day part of the date is returned. Here is the code I am using for this:
print "<td class=general><input type=text name=date value=";
print fixDate($date);
print "></td>";
Any ideas on these problems would be greatly appreciated.