将当前时间转成格林威治时间:

from datetime import datetime, timedelta

import random

local = datetime.now() + timedelta(sencods = random.random())

b = datetime.stftime(local, "%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"

b: 即为当前时间在加上秒数之后的格林威治时间

 

将类似格林威治时间的字符串经过处理转成格林威治时间:

from datetime import datetime, timedelta

import random

date_ = datetime.strptime(start_time, "%Y-%m-%dT%H:%M:%S.%fZ")
 local_time = date_ + timedelta(milliseconds=random.random())
 start_time = datetime.strftime(local_time, "%Y-%m-%dT%H:%M:%S.%f")[:-3] + 'Z'

start_time:即为处理过的格林威治时间

 

相关文章:

  • 2021-08-21
  • 2022-12-23
  • 2022-01-06
  • 2021-12-02
  • 2021-10-03
  • 2022-01-10
  • 2021-12-12
  • 2022-01-20
猜你喜欢
  • 2021-11-09
  • 2021-12-26
  • 2022-12-23
  • 2022-01-20
  • 2021-06-15
  • 2021-12-20
相关资源
相似解决方案