Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- int main(void) {
- struct timespec ts;
- struct tm tm;
- clock_gettime(CLOCK_REALTIME, &ts);
- localtime_r(&ts.tv_sec, &tm);
- printf("tv_sec=%ld, tv_nsec=%ld\n", ts.tv_sec, ts.tv_nsec);
- printf("%d-%02d-%02dT%02d:%02d:%02d.%09ld\n", tm.tm_year + 1900,
- tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
- ts.tv_nsec);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement