w3resource

Python Arrow Module: get the current UTC datetime, local datetime and datetime of a given location using arrow module

Arrow Module: Exercise-1 with Solution

Write a Python program to get the current UTC datetime, local datetime and datetime of a given location using arrow module.

Sample Solution:

Python Code:

import arrow
a = arrow.utcnow()
print("Current datetime:")
print(a)
print("\nCurrent local datetime:")
b = arrow.now()
print(b)
print("\nSpecified local datetime (US/Mountain):")
c = arrow.now('US/Mountain')
print(c)

Sample Output:

Current datetime:
2019-06-04T06:40:36.294600+00:00

Current local datetime:
2019-06-04T12:10:36.295600+05:30

Specified local datetime (US/Mountain):
2019-06-04T00:40:36.295600-06:00

Python Code Editor:

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

Previous: Python Arrow Module Exercises Home.
Next: Write a Python program to create datetime from integers, floats and strings timestamps using arrow module.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/arrow/python-arrow-exercise-1.php