How would I get the current time in ISO 8601 format? It should look something like 2011-11-16T22:06Z
A pure C solution, using only standard C features:
#include <stdio.h>
#include <time.h>
int main(void) {
time_t now = time(NULL);
struct tm *now_tm = gmtime(&now);
char iso_8601[] = "YYYY-MM-DDTHH:MMZ";
/* init just to get the right length */
strftime(iso_8601, sizeof iso_8601, "%FT%RZ", now_tm);
puts(iso_8601);
return 0;
}
use a simple NSDateFormatter call for that -- "yyyy-MM-dd'T'HH:mmZ" or some such. (Don't forget to set Locale to avoid the AM/PM mess.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With