Answers for "times python"

2

python clock

# Here is a self updating clock function, just run it and it'll self update itself until you hit CTRL-C
import datetime
import time
def clock():
    while True:
        print(datetime.datetime.now().strftime("%H:%M:%S"), end="r")
        time.sleep(1)

clock()
Posted by: Guest on July-23-2020
9

time module in python

import time
seconds = time.time()
print("Seconds since epoch =", seconds)
Posted by: Guest on July-30-2020
0

python timestanp

#!/usr/bin/python3
import time
import datetime

start = "10/03/2021 08:00:00"
timestmp_start=int(time.mktime(datetime.datetime.strptime(start, "%d/%m/%Y %H:%M:%S").timetuple()))*1000
date_start=datetime.datetime.fromtimestamp(timestmp_start/1000).strftime("%d/%m/%Y %H:%M:%S")


#output:
#timestmp_start: 1615343400000
#date_start: "10/03/2021 08:00:00"
Posted by: Guest on March-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language