是的,strftime
函数在 Linux 中可以显示星期
#include#include int main() { time_t rawtime; struct tm * timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); printf("Today is %s\n", asctime(timeinfo)); return 0; }
在这个示例中,我们首先使用 time()
函数获取当前时间,然后使用 localtime()
函数将时间转换为本地时间结构。最后,我们使用 asctime()
函数将本地时间结构转换为可读的字符串,其中包含星期几的信息。