-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path02.py
40 lines (23 loc) · 812 Bytes
/
02.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# printing the current date and time in different methods
import datetime
# ---------------(DATE)---------------
print(datetime.datetime.now().strftime("%Y-%m-%d"))
# 2022-07-01
print(datetime.datetime.now().strftime("%b %d, %Y"))
# Jul 01, 2022
print(datetime.datetime.now().strftime("%d-%b-%Y"))
# 01-Jul-2022
print(datetime.datetime.now().strftime("%d/%b/%y"))
# 01/Jul/22
print(datetime.datetime.now().strftime("%a, %d %B %Y"))
# Fri, 01 July 2022
print(datetime.datetime.now().strftime("%x"))
# 07/01/22
# ---------------(TIME)---------------
print(datetime.datetime.now().strftime("%-I:%-M:%-S %P"))
# 2:49:59 pm
print(datetime.datetime.now().strftime("%X"))
# 14:49:59
# ---------------(DATE & TIME)---------------
print(datetime.datetime.now().strftime("%c"))
# Fri Jul 1 14:49:59 2022