I know I can do this if I have a struct tm structure, but what if I want to do the same thing with a SYSTEMTIME. I could do this manually but just wondering if there's function that does this already.
Thanks
void PrintTimeSCII(struct tm *time)
{
char timebuf[26] = {0};
asctime_s(timebuf, 26, time);
printf("%s\n", timebuf);
}
Michael
GetDateFormat can be used for this. It can format the date using the appropriate format for a given locale. Below code shows how to use it for the user's default locale, in short format.
char timebuf[26];
GetDateFormat(LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&sysTime,
NULL,
timebuf,
ARRAYSIZE(timebuf));
来源:https://stackoverflow.com/questions/3121734/is-there-a-function-like-asctime-s-that-works-for-systemtime-structures-in-win