String to DateTime Object

I am new to string functions, so I need the complicated substr and trim function for this string:

Wed, 28 Dec 2011 13:04:30 GMT 

A string always comes to me with this format. I want to convert it to a DateTime object. Can anybody help me?

+6
source share
2 answers
 $dateString = 'Wed, 28 Dec 2011 13:04:30 GMT'; $dateTime = datetime::createfromformat('D, d MYH:i:s e',$dateString); echo $dateTime->format('dMY H:i:s e'); 
+14
source
 <?php $date = new DateTime('Wed, 28 Dec 2011 13:04:30 GMT'); echo $date->format('r'); 

... prints:

 Wed, 28 Dec 2011 13:04:30 +0000 
+10
source

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


All Articles