2

I have encountered this date format:

2013-03-12T09:16:12.1550656+01:00

from what I have found in net this is ISO 8601 (am I correct?).

How can I convert this this date format using php?

I can generate it easily using date('c'), but I need convert this type of date:

20130422122037 - (YYYYMMDDHHMMSS)
baron_bartek
  • 1,073
  • 2
  • 20
  • 39
  • see the link http://stackoverflow.com/questions/2487921/convert-date-format-yyyy-mm-dd-dd-mm-yyyy – Code Lღver Apr 23 '13 at 11:47
  • This question has already been answered: http://stackoverflow.com/questions/6458585/using-php-how-convert-an-iso8601-date-to-a-different-format – Zim84 Apr 23 '13 at 11:49
  • this is one of the formats that [`strtotime()`](http://uk.php.net/manual/en/function.strtotime.php) understands, just use that – Nick Andriopoulos Apr 23 '13 at 11:49
  • Why was my edit removed? if it is iso 8601, the seconds part can only be 2 chars long. – Zim84 Apr 23 '13 at 11:50

1 Answers1

4

Try this:

$date = new DateTime('20130422122037');

var_dump($date->format('c'));
silkfire
  • 24,585
  • 15
  • 82
  • 105