Link to home
Start Free TrialLog in
Avatar of Undisputed
Undisputed

asked on

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

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

2010-03-25T18:00:00.00+00:00

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.
Avatar of svenarild
svenarild

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'));
Avatar of Undisputed

ASKER

I thought that would be the solution too but it does not output the correct time.  It outputs:

2010-03-25 14:00:00
ASKER CERTIFIED SOLUTION
Avatar of svenarild
svenarild

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just another note, you can also use the new DateTime class/function if your using php 5.2 or most preferably 5.3.

http://no.php.net/manual/en/class.datetime.php

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.