Python Arrow Module: Create a string representation of the Arrow object, formatted according to a format string
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.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics