博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux练习(时间变为常用时间)
阅读量:7218 次
发布时间:2019-06-29

本文共 752 字,大约阅读时间需要 2 分钟。

#include 
#include
int main(){ struct tm *tm_ptr; time_t the_time; (void) time(&the_time); tm_ptr=gmtime(&the_time); printf("Raw time is %ld\n",the_time); printf("gmtime gives:\n"); printf("date: %02d/%02d/%02d\n", tm_ptr->tm_year,tm_ptr->tm_mon+1,tm_ptr->tm_mday); printf("time: %02d:%02d:%02d\n", tm_ptr->tm_hour,tm_ptr->tm_min,tm_ptr->tm_sec); return 0;}

函数原型:

#include <time.h>

struct tm *gmtime(const time_t timeval);

tm结构体包括:

int tm_sec;秒,0-61(有润秒)

int tm_min;分,0-59

int tm_hour;小时,0-23

int tm_mday;月份中的日期,1-31

int tm_mon;年份中的月份,0-11(0代表一月)

int tm_year;从1900年开始计算的年份(今年就是112)

int tm_wday;星期几,0-6(0代表周日)

int tm_uday;年份中的日期,0-356

int tm_isdst;日否为夏日制

转载地址:http://kzxym.baihongyu.com/

你可能感兴趣的文章
字符串中的各种方法
查看>>
创建文件夹、新建txt文件
查看>>
js form表单 鼠标移入弹出提示功能
查看>>
LFS7.10——准备Host系统
查看>>
Redis.py客户端的命令总结【三】
查看>>
mac 安装secureCRT
查看>>
/var/adm/wtmp文件太大该怎么办?
查看>>
反应器模式 vs 观察者模式
查看>>
Algernon's Noxious Emissions POJ1121 zoj1052
查看>>
iOS-数据持久化-对象归档
查看>>
iOS开发UI篇—程序启动原理和UIApplication
查看>>
MUI 里js动态添加数字输入框后,增加、减少按钮无效
查看>>
python pip 更换国内安装源(windows)
查看>>
结对编程2后篇
查看>>
oracle exp 和 imp 数据和表结构互相独立导出导入
查看>>
iphone-common-codes-ccteam源代码 CCNSPredicate.m
查看>>
这次项目中应该注意的问题和应该保持的好习惯
查看>>
python-数据结构化与保存
查看>>
LeetCode - 551. Student Attendance Record I
查看>>
Java用户线程和守护线程
查看>>