-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate-time.py
More file actions
25 lines (19 loc) · 742 Bytes
/
date-time.py
File metadata and controls
25 lines (19 loc) · 742 Bytes
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
import datetime
print(datetime.datetime.now())
print(datetime.datetime.today())
#if we want to display the time with timezone, we have to create a object.
import pytz
ist = pytz.timezone('Asia/kolkata')
print(datetime.datetime.now(ist))
print(datetime.datetime.now().year)
#If you want to display just the year-month-daye, you need to format the result as a string
print(datetime.datetime.now().strftime("%Y-%m-%d"))
#To findout all the parameters we can give to strftime(strftime.org)
print(datetime.datetime.now().strftime("%c"))
#fromtimestamp
print(datetime.datetime.fromtimestamp(1555555))
#If I want to use the submodule datetime directly
from datetime import datetime
print(datetime.now())
print(datetime.max)
print(datetime.min)