Python Arrow Module: Create a new Arrow object, representing the "floor" of the timespan of the Arrow object in a given timeframe using arrow module
Write a Python program to create a new Arrow object, representing the "floor" 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.
Sample Solution:
Python Code:
import arrow
print(arrow.utcnow())
print("Hour ceiling:")
print(arrow.utcnow().floor('hour'))
print("\nMinute ceiling:")
print(arrow.utcnow().floor('minute'))
print("\nSecond ceiling:")
print(arrow.utcnow().floor('second'))
Sample Output:
2019-06-01T11:55:37.370000+00:00 Hour ceiling: 2019-06-01T11:00:00+00:00 Minute ceiling: 2019-06-01T11:55:00+00:00 Second ceiling: 2019-06-01T11:55:37+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 create a floating-point representation of the Arrow object, in UTC time using arrow module.
Next: Write a Python program to create a localized, humanized representation of a relative difference in time using arrow module.
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