Python Arrow Module: Get string representing the date, controlled by an explicit format string
Arrow Module: Exercise-26 with Solution
Write a Python program to get string representing the date, controlled by an explicit format string.
Sample Solution:
Python Code:
import arrow
a = arrow.utcnow()
print("Current datetime:")
print(a)
print("\nString representing the date, controlled by an explicit format string:")
print(arrow.utcnow().strftime('%d-%m-%Y %H:%M:%S'))
print(arrow.utcnow().strftime('%Y-%m-%d %H:%M:%S'))
print(arrow.utcnow().strftime('%Y-%d-%m %H:%M:%S'))
Sample Output:
Current datetime: 2019-06-04T07:20:10.079600+00:00 String representing the date, controlled by an explicit format string: 04-06-2019 07:20:10 2019-06-04 07:20:10 2019-04-06 07:20:10
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to get the proleptic Gregorian ordinal of a given date.
Next: Write a Python program to get hourly datetime between two hours.
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-26.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics