I need this:
12 November, 1997
to be reformatted to:
1997-11-12
for inclusion in MySQL database, but I'm struggling with the full month name, is this possible?
Thanks
Darren
I need this:
12 November, 1997
to be reformatted to:
1997-11-12
for inclusion in MySQL database, but I'm struggling with the full month name, is this possible?
Thanks
Darren
$tempDate = '2013-06-09';
$day = date('l', strtotime( $tempDate));// will gives you the week day name
$month = date('jS F Y',strtotime($tempDate));// will format like date 9th June 2013
date("Y-m-d",strtotime("12 November, 1997"));
Returns 1997-11-12
, exactly what you need :)
Hacky method:
$timestamp = strtotime('12 November, 1997');
$sql = "INSERT INTO table (datefield) VALUES (FROM_UNIXTIME($timestamp))";
Somewhat less hacky:
$timestamp = DateTime::CreateFromFormat('j F, Y', '12 November, 1997')->format('U');
$sql = "same as above";