-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2018_12_08_dateTime.py
More file actions
37 lines (28 loc) · 854 Bytes
/
Copy path2018_12_08_dateTime.py
File metadata and controls
37 lines (28 loc) · 854 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
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 8 16:23:00 2018
@author: domenjemec
@title: 2018-12-08 DateTime Worksheet
"""
from datetime import date
from datetime import time
from datetime import datetime
def main():
# DATE OBJECTS
# Get today's date from simple today() method from the date class
today = date.today()
print("Today's date is ", today)
# print out the date's individual components
print("Date Components: ", today.day, today.month, today.year)
# retrieve today's weekday 0-6 Sunday
print("Day count is ", today.weekday())
# DATETIME OBJECTS
# Get today's date from the datetime class
today = datetime.now()
print("Datetime is ", today)
# Get the current time
t = datetime.time(today)
print("time is ", t)
if __name__ == "__main__":
main()