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 

demo


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -