#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
_tzset(); // Set time zone
char tm[9];
errno_t err = _strtime_s(tm, 9);
if (err) {
printf("_strdate_s error");
exit(1);
}
printf("OS time: %s\n", tm);
err = _strdate_s(tm, 9);
if (err) {
printf("_strdate_s error");
exit(1);
}
printf("OS date: %s\n", tm);
char ch = getchar();
return 0;
}
/*
run:
OS time: 11:47:04
OS date: 04/08/22
*/