1import time
2milliseconds = int(round(time.time() * 1000))
3print(milliseconds)
1from datetime import datetime as d
2import time as t
3from os import system as clear
4cls = lambda: clear("clear")
5
6prev = d.now()
7prev = prev.strftime("%Y-%m-%d %H:%M:%S")
8
9while True:
10 time = d.now()
11 time = time.strftime("%Y-%m-%d %H:%M:%S")
12 print(time)
13 if not time == prev:
14 prev = time
15 t.sleep(1)
16 cls()
17
1---------------------------------------------------------
2import datetime
3
4currentDateTime = datetime.datetime.now()
5print(currentDateTime)
6---------------------------------------------------------
7OR
8---------------------------------------------------------
9from datetime import datetime
10
11currentDateTime = datetime.now()
12print(currentDateTime)
13---------------------------------------------------------
14OR
15---------------------------------------------------------
16import datetime
17
18print(datetime.datetime.now())
19---------------------------------------------------------
20OR
21---------------------------------------------------------
22from datetime import datetime
23
24print(datetime.now())
25---------------------------------------------------------