mktime 用于将年月日时分秒转换为秒
来源:互联网 发布:双程网络剧第一季 编辑:程序博客网 时间:2024/05/16 08:32
/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
* => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
*
* [For the Julian calendar (which was used in Russia before 1917,
* Britain & colonies before 1752, anywhere else before 1582,
* and is still in use by some communities) leave out the
* -year/100+year/400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think).
*
* WARNING: this function will overflow on 2106-02-07 06:28:16 on
* machines where long is 32-bit! (However, as time_t is signed, we
* will already get problems at other places on 2038-01-19 03:14:08)
*/
unsigned long
mktime(const unsigned int year0, const unsigned int mon0,
const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec)
{
unsigned int mon = mon0, year = year0;
/* 1..12 -> 11,12,1..10 */
if (0 >= (int) (mon -= 2)) {
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 */
}
要比较两个时间的大小
time1 = mktime(y1,m1,d1,h1,m1,s1);
time2 = mktime(y2,m2,d2,h2,m2,s2);
interval = time1 - time2
- mktime 用于将年月日时分秒转换为秒
- 年月日时分秒转换为年月
- Date 转换 年月日时分秒
- 把秒转化为年月日时分秒
- 时间操作(Java版)—将毫秒转换为年月日时分秒
- IOS 将毫秒数转换为年月日时分秒的时间
- 如何将数据库中的时间戳数据取出来后转换为年月日时分秒
- Oracle将时分秒转换为秒再计算平均值后转回时分秒格式
- SimpleDateFormat 将时间变成:年月日时分秒
- C#将总秒数转化为年月日时分秒
- 为日期年月日加上时间时分秒
- 将秒转换成时分秒
- 年月日星期时分秒
- C# 年月日时分秒
- 获取年月日时分秒
- 获取年月日时分秒
- 年月日时分秒转化为秒 和获取当前时间
- Oracle数据库,将日期更新为另一日期字段的年月日,不改时分秒
- ubuntu与xp双系统,xp上不了网的问题(郁闷)
- 歪答正着-C#常见面试题(征集问题!)
- 教你手绘墙画表现|武汉手绘
- 针对近期搜索引擎调整算法的应对策略
- IBM笔记本电脑错误故障代码列表(转载)
- mktime 用于将年月日时分秒转换为秒
- 杂议2009云计算中国论坛会
- 工作以后十不要:学会说话减少奋斗30年
- 要将linux内核的带级别控制的printk内容打印出来,在命令行 输入 dmesg -n 8 就将所有级别的信息都打印出来
- 在Unbuntu9.04中运行AppEngine
- event.keycode大全(javascript)
- MyEclipse使用技巧和快捷键
- 如何提高读取BSEG的性能(SAP已清项和未清项的管理)
- ORACLE备忘录