c++ time_t
struct tm
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):
|
int tm_sec; |
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-11: real 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.
c++ time_t的更多相关文章
- C语言中两种方式表示时间日期值time_t和struct tm类型的相互转换
使用gmtime函数或localtime函数将time_t类型的时间日期转换为structtm类型: 使用time函数返回的是一个long值,该值对用户的意义不大,一般不能根据其值确定具体的年.月.日 ...
- c++ 时间类型详解 time_t
Unix时间戳(Unix timestamp),或称Unix时间(Unix time).POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00 ...
- time_t 获取的是UCT时间,有时差
int main() { time_t nowTime; time(&nowTime);//获取当前时间(世界时间)//这种写法也一样nowTime=time(NULL) ; //如果要转化为 ...
- 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 ...
- FILETIME, SYSTEMTIME 与 time_t 相互转换
FILETIME, SYSTEMTIME 与 time_t 相互转换 2009-08-24 15:37:14| 分类: 默认分类|举报|字号 订阅 //******************* ...
- time_t转换为DateTime
最近解析文华财经的日线数据. 取得的第一个字段是日期,为time_t格式(long)的. 因为是用C#来写解析程序,所以要转换为DateTime的. time_t是世界时间,要转换为本地时间,所以要加 ...
- clock_t与time_t的区别及联系
clock_t <ctime> Clock type Type capable of representing clock tick counts and support arithmet ...
- time_t和struct tm之间的转换
time_t到struct tm的转换: #include <time.h> struct tm *localtime(const time_t *timep); struct tm到ti ...
- 【转】C/C++中的日期和时间 TIME_T与STRUCT TM转换——2013-08-25 16
http://www.cnblogs.com/Wiseman/archive/2005/10/24/260576.html 摘要: 本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的 ...
- C++中实现 time_t, tm 相互转换
time_t -> tm: localtime tm -> time_t: mktime time_t curTime; time(&curTime); dwCurTime = c ...
随机推荐
- Learning Django: the hard way (1)
Learning Django: the hard way (1) What does "runserver" do? Django provides a light-weight ...
- 《解读window核心编程》 之 字符和字符串处理方式
推荐的字符和字符串处理方式 開始将文本字符串想象为字符的数组,而不是 char 或字节的数组. 用通用数据类型(如 TCHAR/PTSTR )来表示文本字符和字符串. 用明白的数据类型(如 BYTE ...
- java.net.Socket/java.net.ServerSocket-TCP Socket编程
TCP 的 Java 支持 协议相当于相互通信的程序间达成的一种约定,它规定了分组报文的结构.交换方式.包含的意义以及怎样对报文所包含的信息进行解析,TCP/IP 协议族有 IP 协议.TCP 协议和 ...
- shell学习笔记之变量(一)
一.普通变量 1.使用变量之前通常并不需要事先声明,通常赋值的时候创建他们2.默认所有的变量都被看做字符串,并且以字符串存储3.变量区分大小写4.变量名前面添加$符号来访问变量,赋值的时候只需要使用变 ...
- Tomcat的URL中文乱码解决以及传输优化
默认的tomcat容器如果直接使用get方式在url中传中文时,传到后台接收会是乱码. 乱码问题 原因: tomcat默认的在url传输时是用iso8859-1编码. 解决方案一: 在使用get传输参 ...
- JAVA中的protected(详解),以及和clone()方法有关的一些问题
http://blog.csdn.net/ciawow/article/details/8262609 ************************************************ ...
- 請問 localtime() 為什麼不會造成 memory leak?
http://www.programmer-club.com.tw/ShowSameTitleN/vc/22380.html ************************************* ...
- 【算法】转载:Iterative vs. Recursive Approaches
Iterative vs. Recursive Approaches Eyal Lantzman, 5 Nov 2007 CPOL Introduction This arti ...
- 5种漂亮的纯CSS3动画按钮特效
这次我们要来分享一款很不错的CSS3按钮动画,这款CSS3按钮一共有5种动画方式,每一种都是鼠标滑过动画形式,虽然这些动画按钮不是十分华丽,但是小编觉得不像其他按钮那样很难扩展,我们可以修改CSS代码 ...
- 【WPF】Button按钮添加背景图片
只是想做一个很简单的图片按钮而已,不需要那么复杂. <Button x:Name="btn" Width="145" Height="30&qu ...