-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
21 lines (13 loc) · 741 Bytes
/
Copy pathmain.py
File metadata and controls
21 lines (13 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# A date in python is not a data type of its own but we can import a module named datetime to work with dates as date objects.
# The date contains year, month, day, hour, minute, second and microsecond.
import datetime
today = datetime.datetime.now()
print(today)
# return the year and name of weekday
print(today.year)
print(today.strftime("%A"))
# To create a date we can use the datetime() class constructor of the datetime module. The datetime() class requires three parameters to create a date: year, month, day.
my_birthday = datetime.datetime(2001,1,11)
print(my_birthday)
# The datetime object has a method for formatting date objects into readable strings. The method is called strftime().
print(today.strftime("%B %d, %Y"))