Parse date and time from string with time zone using Arrow

后端 未结 4 2126
梦如初夏
梦如初夏 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:34

    Per the current documentation, you can also provide a default timezone for arrow.get(), e.g.:

    s = '2015/12/1 19:00:00'
    tz = 'Asia/Hong_Kong'
    arrow.get(s, tzinfo=tz)
    

    However, as of right now (version 0.12.1) there is a shortcoming where that doesn't work for string-based date parsing. Fortunately, this has been fixed, so the next release of Arrow will integrate this fix.

提交回复
热议问题