ch11_4.c

来自「C语言开发入门与编程实践 源码文件」· C语言 代码 · 共 21 行

C
21
字号
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    time_t now;
    struct tm *local,*gmt;/* 声明local结构变量 */ 
    now = time(NULL);/* 取得系统目前时间 */ 
    
    printf("%d 秒\n",now);
    printf("现在时间:ctime():%s", ctime(&now));/*转为一般时间格式 */ 
    local = localtime(&now);
    printf("本地时间:asctime():%s", asctime(local));/*转为一般时间格式 */
    gmt = gmtime(&now);/*取得格林威治时间 */ 
    printf("格林威治时间:%s", asctime(gmt));

    system("pause");
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?