Skip to content

Commit c3efc54

Browse files
#14 - Python
1 parent 8d1113f commit c3efc54

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
### Python Dates ###
2+
from datetime import datetime
3+
4+
current_time = datetime.now()
5+
birth_time = datetime(1987, 12, 23, 4, 45, 8)
6+
print(current_time, birth_time)
7+
8+
years_passed = current_time - birth_time
9+
print(years_passed)
10+
11+
#! Optional Challenge
12+
format_one = birth_time.strftime('%Y/%d/%m')
13+
print(format_one)
14+
format_two = birth_time.strftime('%B-%d-%Y')
15+
print(format_two)
16+
format_three = birth_time.strftime('%a-%d-%B-%y')
17+
print(format_three)
18+
format_four = birth_time.strftime('%a-%d-%B-%y')
19+
print(format_three)
20+
format_five= birth_time.strftime('%d-%B-%y-%H')
21+
print(format_five)
22+
format_six = birth_time.strftime('%d-%a-%B-%Y-%H')
23+
print(format_six)
24+
format_seven = birth_time.strftime('%d-%a-%B-%Y-%I%p')
25+
print(format_seven)
26+
format_eighth = birth_time.strftime('%d-%a-%B-%y-%I%p-00:%M')
27+
print(format_eighth)
28+
format_nine = birth_time.strftime('%d-%a-%B-%y-%I%p-00:%M-00:%S')
29+
print(format_nine)
30+
format_ten = birth_time.strftime('%d-%a/%B/%y/ %I:%M:%S %p')
31+
print(format_ten)

0 commit comments

Comments
 (0)