当前位置: 技术问答>linux和unix
如何计算从Jan,1,1970,00:00:00GMT算起至当前时间的秒数?
来源: 互联网 发布时间:2015-08-31
本文导语: 如何计算从Jan,1,1970,00:00:00GMT算起至当前时间的秒数? 自己写算法,如何计算? | if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ mon += 12; /* Puts Feb ...
如何计算从Jan,1,1970,00:00:00GMT算起至当前时间的秒数?
自己写算法,如何计算?
自己写算法,如何计算?
|
if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */
mon += 12; /* Puts Feb last since it has leap day */
year -= 1;
}
return (((
(unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) +
year*365 - 719499
)*24 + hour /* now have hours */
)*60 + min /* now have minutes */
)*60 + sec; /* finally seconds */
return 的 即是秒数 年数是 后两个数据
mon += 12; /* Puts Feb last since it has leap day */
year -= 1;
}
return (((
(unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) +
year*365 - 719499
)*24 + hour /* now have hours */
)*60 + min /* now have minutes */
)*60 + sec; /* finally seconds */
return 的 即是秒数 年数是 后两个数据