w3resource

Python Arrow Module: Create a datetime object, converted to the specified timezone using arrow module


Write a Python program to create a datetime object, converted to the specified timezone using arrow module.

Sample Solution:

Python Code:

import arrow
utc = arrow.utcnow()
pacific=arrow.now('US/Pacific')
nyc=arrow.now('America/Chicago').tzinfo
print(pacific.astimezone(nyc))

Sample Output:

2019-06-01 06:04:28.600000-05:00

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to create a new Arrow object, cloned from the current one.
Next: Write a Python program to create a new Arrow object, representing the "ceiling" of the timespan of the Arrow object in a given timeframe using arrow module. The timeframe can be any datetime property like day, hour, minute.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.