Getting numeric timezone in specified format
You would have to manually split the string which is formated by %z
as +hhmm
or -hhmm
. %z
has a fixed format. Look at the description of strftime.
Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ), or by no characters if no timezone is determinable.
Build one string with date and time. Build a second string with the offset from UTC with %z
, insert the :
in the second string. Concatenate first and second string.
The syntax you tried don't exist.
What I would do is calling the function twice : once with "%Y-%m-%d %H%M%S "
, and once with "%z"
, manually add the :
in the second string, and then concatenate the two.
To insert the :
, you could do an ugly buffer manipulation :
buf2[5]=buf2[4];buf2[4]=buf2[3];buf2[3]=':';strcat(buf,buf2);
Note that the layout isn't likely to change for this specific data, so it's not so ugly.
0r if you really like overkill, a regexp. But you'll need an external library.