﻿ Python Arrow Module: Create a localized, humanized representation of a relative difference in time using arrow module - w3resource

# Python Arrow Module: Create a localized, humanized representation of a relative difference in time using arrow module

## Arrow Module: Exercise-18 with Solution

Write a Python program to create a localized, humanized representation of a relative difference in time using arrow module.

Sample Solution:

Python Code:

``````import arrow
print("Current datetime:")
print(arrow.utcnow())
earlier = arrow.utcnow().shift(hours=-4)
print(earlier.humanize())
later = earlier.shift(hours=3)
print(later.humanize(earlier))
``````

Sample Output:

```Current datetime:
2019-06-01T11:59:21.976000+00:00
4 hours ago
in 3 hours
```

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Python: Chaining Of Comparison Operators

Example:

```n = 20
test = 1 < n < 30
print(test)
```

Output:

```True
```

Example:

```test = 1 > n <= 9
print(test)
```

Output:

```False
```