Date and Time

 

Date and Time lesson in CodeAcademy teaches me about the setting variable equal to a statement and using string substitution.  The first two screen shot shows a function datetime to show  the current year, month, day, hour, minute and second. The variable now is set to datetime.now. We print now and receive the current date.

snip20161211_6

 

snip20161211_8

 

 

 

 

 

 

Here’s another way to get current date. The next screenshot has the same first two line only it also consists of other variables such as current_year, current_month, and current_day. current_year is set to now_year, current_month is set to now_month, current_day is set to now_day. We print each variable and it prints the current date.

2016

12

11

snip20161211_9

 

 

 

 

Another form to write the date is using string substitution. We have the same first two lines and the next line is a print function. What we are printing is the symbol of substitution which is ‘%s’, three times in between each one has a / symbol with a % after it, ‘%s/%s/%/s’. The argument would be in order as followed: now_month, now_day and now_year.

12/11/2016

snip20161211_10

From the previous screen shot it’s the same concept only we are now looking into the time. The same two lines. We have in the next line print, then the substation symbol is repeated three times with a : in between each symbol, ‘%s:%s:%s’ with separate % after it. The argument would be in order as followed: now_hour, now_minute and now_second.

23:57:21

snip20161211_11

The last screenshot is a combination of the previous two. The difference is that it’s typed out “%s/%s/%s %s:%:s%s” the % is placed after. The argument would be in order as followed: now_month, now_day, now_year, now_hour, now_minute and now_second.

12/11/16 23:59:43

snip20161211_12