get the current system datetime

https:‮l.www//‬autturi.com
get the current system datetime

In C language, how to obtain the current year, month and day?

You can use the GetLocalTime or GetSystemTime function to obtain the current system time.

#include <windows.h>
#include <stdio.h>

int main(void) {

    SYSTEMTIME t;

    GetLocalTime(&t);

    printf("year: %d, month: %d, day: %d, hour: %d, minute:%d, second: %d, millisecond: %d",
            t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, t.wMilliseconds);

    return 0;
}

output:

year: 2020, month: 8, day: 23, hour: 22, minute:58, second: 49, millisecond: 10
Process returned 0 (0x0)   execution time : 2.290 s
Created Time:2017-08-28 19:26:28  Author:lautturi