LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 509|回复: 0

看文档一定要仔细,关于*nix中的时间structure: time_t tm

[复制链接]
发表于 2005-9-3 22:05:34 | 显示全部楼层 |阅读模式
:rolleyes:

UNIX systems all use the same starting point for times and dates: [color="red"]midnight GMT on January 1, 1970.
This is the”start of the UNIX epoch” and Linux is no exception.
All times in a Linux system are measured
as seconds since then. This is similar to the way MS-DOS handles times, except that the MS-DOS epoch
started in 1980. Other systems use other epoch start times.

Get a time value (structure: time_t) with time(),
then break it into details with gmtime(), or localtime(), get a structure tm.

  Broken-down time is stored in the structure tm which is defined in <time.h> as follows:

              struct tm {
                      int     tm_sec;         /* seconds */
                      int     tm_min;         /* minutes */
                      int     tm_hour;        /* hours */
                      int     tm_mday;        /* day of the month */
                      int     tm_mon;         /* month */
                      int     tm_year;        /* year */
                      int     tm_wday;        /* day of the week */
                      int     tm_yday;        /* day in the year */
                      int     tm_isdst;       /* daylight saving time */
              };

tm Member    Description
int tm_sec   Seconds, 0-61
int tm_min   Minutes, 0-59
int tm_hour  Hours, 0-23
int tm_mday  Day in the month, 1-31
int tm_mon   Month in the year, 0-11(January= 0)
[color="red"]int tm_year  Years since 1900 :rolleyes:
int tm_wday Day in the week, 0-6. (Sunday = 0)
int tm_yday  Day in the year, 0-365

int tm_isdst Daylight savings in effect
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表