简体   繁体   中英

Arrow locale not working

arrow.get(datetime.now(), 'Asia/Shanghai').date()

Returns datetime.date(2017, 3, 26) but it is 27th March there. How do I fix this?

Documentation gives example over starting with utc then applying the timezone. For your case:

import arrow
utc = arrow.utcnow()
utc.to('Asia/Shanghai').date()

should give you the local date you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM