tags:

views:

25

answers:

1

Is there any C++ Library api available which converts Unix timestamp to XML datatype datetime

eg :

http://books.xmlschemata.org/relaxng/ch19-77049.html

I am looking to convert into pattern : 2001-10-26T19:32:52+00:00

I also have access to mysql, so I can get hold of :

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2010-09-28 14:47:47 | 
+---------------------+

I could not find any formatting functions which would fit this.

I just don't prefer string manipulation for this , unless there is no way out....

Cheers!

+3  A: 

You could use the strftime() function from <time.h>:

char time_buf[21];
time_t now;
time(&now);
strftime(time_buf, 21, "%Y-%m-%dT%H:%S:%MZ", gmtime(&now));
Bart van Ingen Schenau
Wunderbaar! Thanks!
Ricko M