Programming Tips - Win32: make a timestamp in Windows

Date: 2014sep26 Level: beginner OS: Windows Platform: win32 Language: C/C++ Q. Win32: make a timestamp in Windows A. Use GetLocalTime() like this:
LPCSTR TimeStamp(LPSTR buf, const size_t size) { SYSTEMTIME now; GetLocalTime(&now); _snprintf_s(buf, size, _TRUNCATE, "%04d.%02d.%02d %02d:%02d:%02d" , now.wYear, now.wMonth, now.wDay , now.wHour, now.wMinute, now.wSecond); return buf; }