Parse date and time from string with time zone using Arrow

后端 未结 4 2113
梦如初夏
梦如初夏 2021-02-20 12:08

I have

import arrow
s = \'2015/12/1 19:00:00\'
tz = \'Asia/Hong_Kong\'

How can I parse this with Arrow such that I get an Arrow object with the

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 12:36

    This is working for me as of 0.10.0:

    import arrow
    s = '2015/12/1 19:00:00'
    tz = 'Asia/Hong_Kong'
    
    arrow.get(s, 'YYYY/M/D HH:mm:ss', tzinfo=tz)
    # 
    

    However, arrow.get('2018-01-29 14:46', tzinfo='US/Central') (i.e. without the format string) ignores the tzinfo parameter.

提交回复
热议问题