Get time zone information of the system in Python?

前端 未结 8 1131
情歌与酒
情歌与酒 2020-12-02 11:40

I want to get the default timezone (PST) of my system from Python. What\'s the best way to do that? I\'d like to avoid forking another process.

8条回答
  •  感情败类
    2020-12-02 12:25

    This should work:

    import time
    time.tzname
    

    time.tzname returns a tuple of two strings: The first is the name of the local non-DST timezone, the second is the name of the local DST timezone.

    Example return: ('MST', 'MDT')

提交回复
热议问题