type

struct tm

<ctime>
Time structure

Structure containing a calendar date and time broken down into its components.

The structure contains nine members of type int, which are (in any order):

1
2
3
4
5
6
7
8
9
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
而直接存储年月日的是一个结构:
struct tm
{
    int tm_sec;  /*秒,正常范围0-59, 但允许至61*/
    int tm_min;  /*分钟,0-59*/
    int tm_hour; /*小时, 0-23*/
    int tm_mday; /*日,即一个月中的第几天,1-31*/
    int tm_mon;  /*月, 从一月算起,0-11*/  1+p->tm_mon;
    int tm_year;  /*年, 从1900至今已经多少年*/ 1900+ p->tm_year;
    int tm_wday; /*星期,一周中的第几天, 从星期日算起,0-6*/
    int tm_yday; /*从今年1月1日到目前的天数,范围0-365*/
    int tm_isdst; /*日光节约时间的旗标*/
};

需要特别注意的是,年份是从1900年起至今多少年,而不是直接存储如2011年,月份从0开始的,0表示一月,星期也是从0开始的, 0表示星期日,1表示星期一。

The meaning of each is:

Member Meaning Range
tm_sec seconds after the minute 0-61*
tm_min minutes after the hour 0-59
tm_hour hours since midnight 0-23
tm_mday day of the month 1-31
tm_mon months since January 0-11real month = tm_mon + 1
tm_year years since 1900  1900+tm_year
tm_wday days since Sunday 0-6
tm_yday days since January 1 0-365
tm_isdst Daylight Saving Time flag  

The Daylight Saving Time flag (tm_isdst) is greater than zero if Daylight Saving Time is in effect, zero if Daylight Saving Time is not in effect, and less than zero if the information is not available.

tm_sec is generally 0-59. Extra range to accommodate for leap seconds in certain systems.

 
 
time

c++ time_t的更多相关文章

  1. C语言中两种方式表示时间日期值time_t和struct tm类型的相互转换

    使用gmtime函数或localtime函数将time_t类型的时间日期转换为structtm类型: 使用time函数返回的是一个long值,该值对用户的意义不大,一般不能根据其值确定具体的年.月.日 ...

  2. c++ 时间类型详解 time_t

    Unix时间戳(Unix timestamp),或称Unix时间(Unix time).POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00 ...

  3. time_t 获取的是UCT时间,有时差

    int main() { time_t nowTime; time(&nowTime);//获取当前时间(世界时间)//这种写法也一样nowTime=time(NULL) ; //如果要转化为 ...

  4. c time_t 和 oc NSDate 的转换

    c time_t 和 oc NSDate 的转换 1:time_t 转 oc NSDate time_t some_time_t=NULL; NSDate *someDate = [NSDate da ...

  5. FILETIME, SYSTEMTIME 与 time_t 相互转换

    FILETIME, SYSTEMTIME 与 time_t 相互转换 2009-08-24 15:37:14|  分类: 默认分类|举报|字号 订阅     //******************* ...

  6. time_t转换为DateTime

    最近解析文华财经的日线数据. 取得的第一个字段是日期,为time_t格式(long)的. 因为是用C#来写解析程序,所以要转换为DateTime的. time_t是世界时间,要转换为本地时间,所以要加 ...

  7. clock_t与time_t的区别及联系

    clock_t <ctime> Clock type Type capable of representing clock tick counts and support arithmet ...

  8. time_t和struct tm之间的转换

    time_t到struct tm的转换: #include <time.h> struct tm *localtime(const time_t *timep); struct tm到ti ...

  9. 【转】C/C++中的日期和时间 TIME_T与STRUCT TM转换——2013-08-25 16

    http://www.cnblogs.com/Wiseman/archive/2005/10/24/260576.html 摘要: 本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的 ...

  10. C++中实现 time_t, tm 相互转换

    time_t -> tm: localtime tm -> time_t: mktime time_t curTime; time(&curTime); dwCurTime = c ...

随机推荐

  1. Django内置过滤器详解附代码附效果图--附全部内置过滤器帮助文档

    前言 基本环境 Django版本:1.11.8 Python版本:3.6 OS: win10 x64 本文摘要 提供了常用的Django内置过滤器的详细介绍,包括过滤器的功能.语法.代码和效果示例. ...

  2. 常见电源品牌大揭密(转贴自pceva,作者royalk)

    常见电源品牌大揭密(转贴自pceva,作者royalk) 介绍电源品牌代工厂之前,必须介绍一下电源分类: 标准电源 标准电源就是电脑城装机用得最多的电源,性能正常,外观一般,原生接线,也没有什么风扇停 ...

  3. JavaEE各种Javadoc的下载

    刚才突然发现,很多servlet的api都不熟悉,但是又没有给eclipse导入api,就google了一下 关键字,servlet api / doc 或者java ee api / doc 注意版 ...

  4. LeetCode: Letter Combinations of a Phone Number 解题报告

    Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...

  5. dp:FZU2030括号问题

    http://acm.fzu.edu.cn/problem.php?pid=2030 给出一个字符串,其中包括3种字符: ‘(‘, ‘)’, ‘?’.其中?表示这个字符可以是’(‘也可以是’)’. 现 ...

  6. Android Studio使用心得

    说实话 開始接触这个工具 真的认为非常恶心 毕竟大陆被墙  非常多东西用起来不是非常方便 并且Eclipse转到Android Studio还是一个跨度 废话不多说  以下 讲下我遇到的问题 1. 安 ...

  7. VMWare虚拟机安装创建虚拟机的使用教程

    VMWare虚拟机安装创建虚拟机的使用教程   在配置虚拟机之前需要安装它,VMWare软件的安装过程比较简单,在安装在之前应该先看下说明文档.下面以VMWare Workstation6.5虚拟机 ...

  8. WF追忆

    前一阵子学习了一下工作流,现在写个总结记录一下这个过程.要弄工作流,首先就要有个界面来画图,做web的,没办法,只能选择javascript和silverlight,找来找去,最后用了Shareide ...

  9. iOS开发小技巧--定义宏和pch文件的使用

    一.创建pch文件,默认跟项目同名 二.告诉系统,编译的时候要编译pch文件的步骤 三.把经常用到的宏  或者  分类 包含到这里

  10. iOS彩票项目--第三天,搭建竞技场和发现,搭建幸运选号和我的彩票界面

    一.竞技场搭建--UISegmentedControl的使用 // 重写 自定义控制器的view - (void)loadView { UIImageView *imgView = [[UIImage ...