1import sys
2from tkinter import *
3import time
4
5def times():
6 current_time=time.strftime("%H:%M:%S")
7 clock.config(text=current_time)
8 clock.after(200,times)
9
10
11root=Tk()
12root.geometry("500x250")
13clock=Label(root,font=("times",50,"bold"),bg="black",fg='blue')
14clock.grid(row=2,column=2,pady=25,padx=100)
15times()
16
17digi=Label(root,text="Digital clock",font="times 24 bold",fg="violet")
18digi.grid(row=0,column=2)
19
20nota=Label(root,text="hours minutes seconds ",font="times 15 bold")
21nota.grid(row=3,column=2)
22
23root.mainloop()
24
1
2from datetime import datetime
3
4timestamp = 1528797322
5date_time = datetime.fromtimestamp(timestamp)
6
7print("Date time object:", date_time)
8
9d = date_time.strftime("%m/%d/%Y, %H:%M:%S")
10print("Output 2:", d)
11
12d = date_time.strftime("%d %b, %Y")
13print("Output 3:", d)
14
15d = date_time.strftime("%d %B, %Y")
16print("Output 4:", d)
17
18d = date_time.strftime("%I%p")
19print("Output 5:", d)
20
1# Here is a self updating clock function, just run it and it'll self update itself until you hit CTRL-C
2import datetime
3import time
4def clock():
5 while True:
6 print(datetime.datetime.now().strftime("%H:%M:%S"), end="\r")
7 time.sleep(1)
8
9clock()