-1

What I Require

How can I convert 2013-07-26T10:00:00.000+05:30 to Y-m-d H:i:s format.

I need to get 2013-07-26 10:00:00 from this.

.

What I Tried

 $dateTime = DateTime::createFromFormat(DateTime::ISO8601,2013-07-26T10:00:00.000+05:30);
 echo $dateTime->format('Y-m-d H:i:s');

AND

 $dateTime = DateTime::createFromFormat(DateTime::ISO8601, srtotime(2013-07-26T10:00:00.000+05:30));
 echo $dateTime->format('Y-m-d H:i:s');

Note: The date was obtained from google calendar's event start and end date.

Developer
  • 1,030
  • 6
  • 14
  • 37

3 Answers3

2

The second argument for createFromFormat should be the string representing the time, not a timestamp. Try removing strtotime and passing in the string directly.

Alternatively you could do:

echo date('Y-m-d H:i:s', strtotime('2013-07-26T10:00:00.000+05:30'));
bstonehill
  • 361
  • 2
  • 7
2

Use DateTime

$date = new DateTime('2013-07-26T10:00:00.000+05:30');
echo $date->format('Y-m-d H:i:s');
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
0

Try this code

$datetime="2013-07-26T10:00:00.000+05:30";
$time=strtotime($datetime);
echo date("Y-m-d H:i:s",$time);
Janith Chinthana
  • 3,792
  • 2
  • 27
  • 54