Convert "Day Date Of Month YYYY" To YYYY-MM-DD In Php -
how convert "friday 20th of march 2015" "2015-03-20" in php ?
options tried (failed):
$time = strtotime(stripslashes("friday 20th of march 2015")); echo date("y-m-d",$time); $time = strtotime("friday 20th of march 2015"); echo date("y-m-d",$time);
option 2 (failed):
$old_date = date('friday 20th of march 2015'); $old_date_timestamp = strtotime($old_date); $new_date = date('y-m-d', $old_date_timestamp); echo $new_date;
option 3 (failed):
$date = datetime::createfromformat('l d of f y', 'friday 20th of march 2015'); $new_date_format = $date->format('y-m-d'); echo $new_date_format;
duplicate entries didn't work out: how convert "day, dd month yyyy" "yyyy-mm-dd" in php
this code works:
$date = datetime::createfromformat('l ds \o\f f y', 'friday 20th of march 2015'); $new_date_format = $date->format('y-m-d'); echo $new_date_format;
Comments
Post a Comment