I have a date in string format DD-MM-YYYY
.
date_string = "08-01-2008";
I would like to extract the day, month, year information from date_string
such that;
day="08";
month="01";
year="2008";
How can this be done in php?
I have a date in string format DD-MM-YYYY
.
date_string = "08-01-2008";
I would like to extract the day, month, year information from date_string
such that;
day="08";
month="01";
year="2008";
How can this be done in php?
$string = "08-01-2208";
$date = DateTime::createFromFormat("d-m-Y", $string);
echo $date->format("d"); //day
echo $date->format("m"); //month
echo $date->format("Y"); //year