Is there any function, in python, that extracts time information from a string to get the time from the current local one? For example:
I have a column with time information in the past compared to the current time (let's say UK time, approximately 20:00)
Time
10 hours # ago
6 hours # ago
12 hours # ago
2 days # ago
1 day # ago
I would like to have, looking at the current UK time, (i.e., approximately 20:00):
New_Time
10:00
14:00
8:00
48:00
24:00
The column above comes from the current local time minus the number of hours (from string to numerical) in Time
column.
Is it something that I might do with a function? The New_Time
is the output that I will need.
In case there might not be a function in python, my approach would be:
- use something to detect the current time (to save it in a variable)
- consider hours as 60 min and 1 day as 24 hours ... in order to run some mathematical operations, once transformed strings into numerical
- subtract from the current time the amount of minutes/hours to go back in time