...

View Full Version : mysql to us date formatting



sir pannels
09-05-2006, 11:18 AM
Hi there,

Trying to take mysql date format and output it as us standard YYYY-DD-MM however it seems to be ignoring my date.. here is my code...


<?
$oldDate="2005-12-01";
$newDate = date("m-d-Y", $oldDate);
echo $newDate;
?>
// This returns :
1970-01-01

Any ideas?
Cheers,
Sir P

NancyJ
09-05-2006, 12:49 PM
This is a php question not a mysql question but


<?
$oldDate="2005-12-01";
$newDate = date("m-d-Y", strtotime($oldDate));
echo $newDate;
?>

sir pannels
09-05-2006, 01:04 PM
Doh sorry :/

Thanks for the code :)

guelphdad
09-05-2006, 02:38 PM
You can do it directly in mysql instead of having to do any of the work in php, just use DATE_FORMAT.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum