Python: date, time formatting

后端 未结 2 768
Happy的楠姐
Happy的楠姐 2020-12-14 02:08

I need to generate a local timestamp in a form of YYYYMMDDHHmmSSOHH\'mm\'. That OHH\'mm\' is one of +, -, Z and then there are hourhs and minutes followed by \'.

Ple

2条回答
  •  萌比男神i
    2020-12-14 02:52

    time.strftime will do for that,

    And in linux, %z will just give you -HHMM format if environment variable is properly set.

    >>> os.environ['TZ'] = 'EST'
    >>> time.strftime('%x %X %z')
    '03/21/10 08:16:33 -0500'
    

提交回复
热议问题