How to convert this date format to php?

I get this date format from facebook and google docs:

2011-02-25T10:55:25+0000 

How can I convert it to something like

 25/02/2011 10:55:25 
+4
source share
4 answers

Use strtotime to get the timestamp.

 $ts = strtotime('2011-02-25T10:55:25+0000'); echo date('d/m/YH:i:s', $ts); 
+4
source
 <?php $date = new DateTime('2011-02-25T10:55:25+0000'); print $date->format('d/m/YH:i:s'); ?> 

Remember to set the correct time zone in this example. See the datetime documentation on php.net for more details.

+10
source

It looks like SOAP .

Try reading it with a DateTime class and displaying it in native format.

See ZeSimon answer for code.

+1
source
  $ out = preg_replace ("/ ^ ([0-9] +) - ([0-9] +) - ([0-9] +) T ([0-9] +: [0-9] +: [0-9] +) \ + ([0-9] +) / "," \ $ 3 / \ $ 2 / \ $ 1 \ $ 4 ", $ in); 
-1
source

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


All Articles