查看当前mysql时区

show variables like "%time_zone%"

查看当前时区加上UTC时区

若当前时区是UTC,查数据库与时间字段相关的数据时,需要加上时区

import pytz

        start_date = datetime.datetime.strptime(str_time, "%Y-%m-%d %H:%M:%S")
   
       a = start_date.replace(tzinfo=pytz.utc)

result = Book.objects.filter(start_date__gte=a)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-17
  • 2022-01-12
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-02-07
  • 2021-11-10
相关资源
相似解决方案