XML dateTime and PHP
July 19, 2011 4 Comments
Today I had to grapple with a Sage based web service and I discovered that XML dateTime formats can give you a large headache
Foolishly I thought that being a format called dateTime, i could simply pass the webservice a standard PHP date string 19/7/2011 10:05:55 generated by the php date function
date('d/m/Y H:i:s');
But the date would not appear on the receiving end of the web service, the data was simply being invalidated every time. This is due to the fact that the xsd:dateTime (XML scheme definition) format is a ISO8601 formatted type, and is a concatenation of xsd:date and xsd:time. The overall format of the date comes out like 2011-07-11T13:20:00+01:00, with T being the concatenation and the +1:00 being the UTC timezone offset. Nicely enough PHP can generate this type of timestamp with our friend the date function, simply run:
date('c');
Wasn’t too difficult was it :p
Facebook
Google Profile
LinkedIn
PSN
Spotify
Steam
Twitter

Hi Dan Richards,
Thanks for solutions. Its really helped me to solve the date time issue with php and xml
No worries, glad to be of service
nice solutions…..thankyou so much
You save my day … thanks !!