Skip to content

Instantly share code, notes, and snippets.

@adrianlzt
Created January 18, 2018 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianlzt/9c6933675479d52a368142b4eda39085 to your computer and use it in GitHub Desktop.
Save adrianlzt/9c6933675479d52a368142b4eda39085 to your computer and use it in GitHub Desktop.
#define _XOPEN_SOURCE
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
int main(void) {
char buf[100];
struct tm tm1, tm2;
memset(&tm1, 0, sizeof(struct tm));
memset(&tm2, 0, sizeof(struct tm));
strptime("1/1/1970 00:00:00", "%d/%m/%Y %H:%M:%S", &tm1);
strptime("1/1/1970 00:00:00", "%d/%m/%Y %H:%M:%S", &tm2);
strftime(buf, 100, "%s", &tm1);
printf("strftime: %s\n", buf);
time_t seg = mktime(&tm2);
printf("mktime: %ld\n", seg);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment