Skip to content

Commit 601ba8a

Browse files
authored
Update unixtime_convert.py
1 parent 84fa90d commit 601ba8a

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

unixtime_convert.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
###convert unix team to human readable time. This works if the unix time is in milliseconds.
44

5-
import datetime
5+
from datetime import datetime,timedelta
66

77

8-
time = input("Enter the Cyclone event time to be converted: ")
8+
def milltohuman():
9+
time = input("Enter the Cyclone event time to be converted: ")
910

1011
#convert to seconds
11-
fix = int(time) / 1000
12+
fix = int(time) / 1000
1213

13-
value = datetime.datetime.fromtimestamp(fix)
14+
value = datetime.datetime.fromtimestamp(fix)
15+
#return the human readable format
16+
return value.strftime('%Y-%m-%d %H:%M:%S')
1417

15-
print(value.strftime('%Y-%m-%d %H:%M:%S'))
1618

1719

1820

19-
from datetime import datetime,timedelta
2021

2122
date = datetime.now()
2223
test = "2019/08/29 12:13:00"

0 commit comments

Comments
 (0)