做c/s开发,肯定要与时间打交道。
很多时候,获取本地的时间,也就是大陆境内的东八区时间。但是为了保证国际化,服务器往往采用的是0区的时间。
之前博客介绍了C++中关于时间的函数:
http://blog.youkuaiyun.com/wangshubo1989/article/details/50500515
首先明确几个概念:
UTC时间与GMT时间
Greenwich Mean Time (GMT) is a term originally referring to mean solar time at the Royal Observatory, Greenwich where a system was first developed around 1850 for tracking time based on the rotation of the Earth. It is now often used to refer to Coordinated Universal Time (UTC) when this is viewed as a time zone.
UTC与GMT的区别:
时间戳
时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数
本地时间
UT