Programming Tips - How can I make a timestamp on Windows?

Date: 2014sep26 Level: beginner OS: Windows Platform: win32 Language: C/C++ Q. How can I make a timestamp on 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; }