php - Separate date in the format {day-month-year} -
i have code print date in format sun, 09 mar 2014 08:31:14 gmt
i want take date , shorten can print
- the day
- the month
- the year
but want print each separately , want print month in numbers
here code tried
$date = $item->pubdate; echo '.$date.';
you should make use of createfromformat
of datetimeclass
<?php $dt='sun, 09 mar 2014 08:31:14 gmt'; $date = datetime::createfromformat('d, d m y g:i:s o', $dt); echo "day : ".$date->format('d'); // 09 echo "month : ".$date->format('m'); //03 echo "year : ".$date->format('y'); //2014
Comments
Post a Comment