Python Arrow Module: Create a string representation of the Arrow object, formatted according to a format string
Arrow Module: Exercise-10 with Solution
Write a Python program to create a string representation of the Arrow object, formatted according to a format string.
Sample Solution:
Python Code:
import arrow
print("Current datetime:")
print(arrow.utcnow())
print("\nYYYY-MM-DD HH:mm:ss ZZ:")
print(arrow.utcnow().format('YYYY-MM-DD HH:mm:ss ZZ'))
print("\nDD-MM-YYYY HH:mm:ss ZZ:")
print(arrow.utcnow().format('DD-MM-YYYY HH:mm:ss ZZ'))
print(arrow.utcnow().format('\nMMMM DD, YYYY'))
print(arrow.utcnow().format())
Sample Output:
Current datetime: 2019-06-01T10:46:04.205000+00:00 YYYY-MM-DD HH:mm:ss ZZ: 2019-06-01 10:46:04 +00:00 DD-MM-YYYY HH:mm:ss ZZ: 01-06-2019 10:46:04 +00:00 June 01, 2019 2019-06-01 10:46:04+00:00
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to convert timezone from local to utc, utc to local or specified zones.
Next: Write a Python program to create a new Arrow object, cloned from the current one.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
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://w3resource.com/python-exercises/arrow/python-arrow-exercise-10.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics