How to convert date to US formatting in PHP?

Possible duplicate:
PHP: convert date format yyyy-mm-dd => dd-mm-yyyy [NOT IN SQL]

I hope everyone has a great holiday.

I have a date in this format: 23-12-2011 and would like to cancel it in the US format 2011-12-23 .

Does anyone know how I can do this in PHP? Is there any function to split the lines?

+4
source share
2 answers
 date("Ymd", strtotime("23-12-2011")) 
+4
source
 $date = DateTime::createFromFormat('dm-Y', '23-12-2011'); echo $date->format('Ym-d'); 

Voila. Check datetime class PHP5s

+7
source

Source: https://habr.com/ru/post/1387716/


All Articles