#include<stdio.h>
#include<time.h>
int main(void){
time_t now = time(NULL);
printf("%s\n", ctime(&now));
return 0;
}
This is compiled using GCC and run. Result: Wed May 10 19:13:18 2023 Actual: Sat May 13 09:45:37 2023 (PC system time as correctly displayed) Why the difference? The code could not be simpler!
Environment: I'm running Windows Subsystem for Linux WSL2 on a Windows 11 PC. I don't know if that is significant
Tried researching for similar problems - but this is not a UTC/local time issue.