3

我知道如果我有一个 struct tm 结构我可以做到这一点,但如果我想用 SYSTEMTIME 做同样的事情怎么办。我可以手动执行此操作,但只是想知道是否已有功能可以执行此操作。

谢谢

 void PrintTimeSCII(struct tm *time)
 {
     char timebuf[26] = {0};

     asctime_s(timebuf, 26, time);
    printf("%s\n", timebuf);
 }
4

1 回答 1

1

GetDateFormat可用于此。它可以使用给定语言环境的适当格式来格式化日期。下面的代码以简短的格式显示了如何将其用于用户的默认语言环境。

char timebuf[26];
GetDateFormat(LOCALE_USER_DEFAULT, 
              DATE_SHORTDATE,
              &sysTime,
              NULL,
              timebuf, 
              ARRAYSIZE(timebuf));
于 2010-06-25T22:12:33.033 回答