Python: Figure out local timezone

前端 未结 18 1626
野性不改
野性不改 2020-12-07 15:50

I want to compare UTC timestamps from a log file with local timestamps. When creating the local datetime object, I use something like:

>>&         


        
18条回答
  •  失恋的感觉
    2020-12-07 16:20

    You may be happy with pendulum

    >>> pendulum.datetime(2015, 2, 5, tz='local').timezone.name
    'Israel'
    

    Pendulum has a well designed API for manipulating dates. Everything is TZ-aware.

提交回复
热议问题