w3resource

Python Arrow Module: Get hourly datetime between two hours

Arrow Module: Exercise-27 with Solution

Write a Python program to get hourly datetime between two hours.

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:

2019-06-04T11:00:00+00:00

2019-06-04T11:59:59.999999+00:00
2019-06-04T12:00:00+00:00

2019-06-04T12:59:59.999999+00:00
2019-06-04T13:00:00+00:00

2019-06-04T13:59:59.999999+00:00
2019-06-04T14:00:00+00:00

2019-06-04T14:59:59.999999+00:00
2019-06-04T15:00:00+00:00

2019-06-04T15:59:59.999999+00:00
2019-06-04T16:00:00+00:00

2019-06-04T16:59:59.999999+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 get string representing the date, controlled by an explicit format string.

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://w3resource.com/python-exercises/arrow/python-arrow-exercise-27.php