Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

Gray-Ice

个人博客兼个人网站

本篇博文中获取的时间格式是这样的: Sat Feb 20 17:41:09 2021 。

那么代码如下:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <time.h>

int main(void)
{
time_t tm;
tm = time(NULL);
printf("%s\n", ctime(&tm));
return 0;
}

当前时间和日期是由库函数time返回的,它实际上返回的是自Unix纪元即1970年1月1日0点0分0秒(国际标准时间)以来的秒数。下一个库函数ctime把该整数值转换成直观可读的时间格式。(摘抄自Unix网络编程卷一)

本篇完。

评论



愿火焰指引你