Convert ASP date format to PHP date format ('Y-m-d H:i:s')

I'm using a webservice that's written in and my script is in php.  When I receive back the datetime field it is in this format:


Is there way to use this with PHP's date function: date('Y-m-d H:i:s')

I know I can use preg_match or split the string but since I am still learning how to truly master PHP I was hoping to get schooled by an expert in this.
Who is Participating?
svenarildConnect With a Mentor Commented:
Yes, that is correct.

The reason for that is due to your server is not set to the GMT/UTC timezone. The +00:00 means the timezone the time was recorded in.

With other words, since your server is in a different timezone it converts the time so its correct according to the server timezone.

This means that:
2010-03-25 18:00:00 GMT/UTC is the same as 2010-03-25 14:00:00 server time (since its in a different timezone).

If you dont want to convert the time to your timezone, just do this:
date('Y-m-d H:i:s', strtotime(substr('2010-03-25T18:00:00.00+00:00',0,22)));
Just pass along the string of the date to strtotime.

So with other words this will work:
date('Y-m-d H:i:s', strtotime('2010-03-25T18:00:00.00+00:00'));
UndisputedAuthor Commented:
I thought that would be the solution too but it does not output the correct time.  It outputs:

2010-03-25 14:00:00
Just another note, you can also use the new DateTime class/function if your using php 5.2 or most preferably 5.3.

Its a good system to manipulate time, but the problem with it is that it does not support locale setting, which means that if you for example put the locale to German it will not translate the month, day names etc.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.