java 北京时区 unix 时间戳_unix时间戳转换 北京时间要不要加时区

unsigned int xDate2Seconds(_xtime *time){ static unsigned int month[12]={ /*01月*/xDAY*(0), /*02月*/xDAY*(31), /*03月*/xDAY*(31+28), /*04月*/xDAY*(31+28+31), /*05月*/xDAY*(31+28+31+30), /*06月*/xDAY*(31+28+31+30+31), /*07月*/xDAY*(31+28+31+30+31+30), /*08月*/xDAY*(31+28+31+30+31+30+31), /*09月*/xDAY*(31+28+31+30+31+30+31+31), /*10月*/xDAY*(31+28+31+30+31+30+31+31+30), /*11月*/xDAY*(31+28+31+30+31+30+31+31+30+31), /*12月*/xDAY*(31+28+31+30+31+30+31+31+30+31+30) }; unsigned int seconds = 0; unsigned int year = 0; year = time->year-1970; //不考虑2100年千年虫问题 seconds = xYEAR*year + xDAY*((year+1)/4); //前几年过去的秒数 seconds += month[time->month-1]; //加上今年本月过去的秒数 if( (time->month > 2) && (((year+2)%4)==0) )//2008年为闰年 seconds += xDAY; //闰年加1天秒数 seconds += xDAY*(time->day-1); //加上本天过去的秒数 seconds += xHOUR*time->hour; //加上本小时过去的秒数 seconds += xMINUTE*time->minute; //加上本分钟过去的秒数 seconds += time->second; //加上当前秒数
 seconds -= 8 * xHOUR; return seconds;}

将UNIX时间转为UTC+8 即北京时间

取消

评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值