99
1010 <sub >Author:
1111 <a href =" https://www.linkedin.com/in/asabeneh/ " target =" _blank " >Asabeneh Yetayeh</a ><br >
12- <small > First Edition: Nov 22 - Dec 22, 2019 </small >
12+ <small >Second Edition: July, 2021 </small >
1313 </sub >
14- </ div >
14+
1515</div >
1616
1717[ << Day 15] ( ../15_Day_Python_type_errors/15_python_type_errors.md ) | [ Day 17 >>] ( ../17_Day_Exception_handling/17_exception_handling.md )
2020- [ 📘 Day 16] ( #-day-16 )
2121 - [ Python * datetime* ] ( #python-datetime )
2222 - [ Getting * datetime* Information] ( #getting-datetime-information )
23- - [ Formating Date Output Using * strftime* ] ( #formating -date-output-using-strftime )
23+ - [ Formatting Date Output Using * strftime* ] ( #formatting -date-output-using-strftime )
2424 - [ String to Time Using * strptime* ] ( #string-to-time-using-strptime )
2525 - [ Using * date* from * datetime* ] ( #using-date-from-datetime )
2626 - [ Time Objects to Represent Time] ( #time-objects-to-represent-time )
@@ -39,29 +39,29 @@ print(dir(datetime))
3939[' MAXYEAR' , ' MINYEAR' , ' __builtins__' , ' __cached__' , ' __doc__' , ' __file__' , ' __loader__' , ' __name__' , ' __package__' , ' __spec__' , ' date' , ' datetime' , ' datetime_CAPI' , ' sys' , ' time' , ' timedelta' , ' timezone' , ' tzinfo' ]
4040```
4141
42- With dir or help built-in commands it is possible to know the available functions in a certain module. As you can see, in the datetime module there are many functions, but we will focus on _ date_ , _ datetime_ , _ time_ and _ timedelta_ . Let's see them one by one.
42+ With dir or help built-in commands it is possible to know the available functions in a certain module. As you can see, in the datetime module there are many functions, but we will focus on _ date_ , _ datetime_ , _ time_ and _ timedelta_ . Let se see them one by one.
4343
4444### Getting * datetime* Information
4545
4646``` py
4747from datetime import datetime
4848now = datetime.now()
49- print (now) # 2019-12-04 23 :34:46.549883
50- day = now.day # 4
51- month = now.month # 12
52- year = now.year # 2019
53- hour = now.hour # 23
49+ print (now) # 2021-07-08 07 :34:46.549883
50+ day = now.day # 8
51+ month = now.month # 7
52+ year = now.year # 2021
53+ hour = now.hour # 7
5454minute = now.minute # 38
5555second = now.second
5656timestamp = now.timestamp()
5757print (day, month, year, hour, minute)
5858print (' timestamp' , timestamp)
59- print (f ' { day} / { month} / { year} , { hour} : { minute} ' ) # 4/12/2019, 23 :38
59+ print (f ' { day} / { month} / { year} , { hour} : { minute} ' ) # 8/7/2021, 7 :38
6060```
6161
6262Timestamp or Unix timestamp is the number of seconds elapsed from 1st of January 1970 UTC.
6363
64- ### Formating Date Output Using * strftime*
64+ ### Formatting Date Output Using * strftime*
6565
6666``` py
6767from datetime import datetime
@@ -78,7 +78,7 @@ print(f'{day}/{month}/{year}, {hour}:{minute}') # 1/1/2020, 0:0
7878
7979```
8080
81- Time formating
81+ Formatting date time using * strftime * method and the documentation can be found [ here ] ( https://strftime.org/ ) .
8282
8383``` py
8484from datetime import datetime
@@ -102,9 +102,10 @@ time two: 05/12/2019, 01:05:01
102102
103103Here are all the _ strftime_ symbols we use to format time. An example of all the formats for this module.
104104
105- ![ strftime] ( ./images/strftime.png )
105+ ![ strftime] ( .. /images/strftime.png )
106106
107107### String to Time Using * strptime*
108+ Here is a [ documentation] ( https://www.programiz.com/python-programming/datetime/strptimet ) hat helps to understand the format.
108109
109110``` py
110111from datetime import datetime
@@ -188,7 +189,7 @@ print("t3 =", t3)
188189 t3 = 86 days, 22:56:50
189190```
190191
191- 🌕 You are extraordinary. You are 16 steps a head to your way to greatness. Now do some exercises for your brain and for your muscle .
192+ 🌕 You are an extraordinary. You are 16 steps a head to your way to greatness. Now do some exercises for your brain and muscles .
192193
193194## 💻 Exercises: Day 16
194195
0 commit comments