Dota2数据中游戏开始时间保存为Unix时间戳,为了展示需要转换成北京时间。使用localtime()进行计算。
1,使用gmtime将Unix时间戳转换为格林尼治时间
2,使用localtime将Unix时间戳转换为当地时间From | To | Use |
---|---|---|
seconds since the epoch | struct_time in UTC | gmtime() |
seconds since the epoch | struct_time in local time | localtime() |
struct_time in UTC | seconds since the epoch | calendar.timegm() |
struct_time in local time | seconds since the epoch | mktime() |