#define _XOPEN_SOURCE #include #include #include #include int main(int argc, char *argv[]) { struct tm tm; char buf[255]; memset(&tm, 0, sizeof(struct tm)); if (argc != 3) { fprintf(stderr, "Usage:\n %s date format", argv[0]); exit(1); } strptime(argv[1], argv[2], &tm); mktime(&tm); strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm); puts(buf); return 0; }