PHP date format

Tue Oct 26 10:39:39 +0000 2010

How to convert the format in 2010-10-26

+4
source share
3 answers
 echo date('Ym-d', strtotime("Tue Oct 26 10:39:39 +0000 2010")) // 2010-10-26 
+8
source
 echo date('Ym-d'); 
0
source

Using a DateTime Object:

 echo date_format(new DateTime('Tue Oct 26 10:39:39 +0000 2010'), 'Ym-d'); 

or

 $date = new DateTime('Tue Oct 26 10:39:39 +0000 2010'); echo $date->format('Ym-d'); 
0
source

All Articles