Datetime module is python has the classes and functions for manipulating date and time.
To manipulate date and time operations in python you have to import datetime module.
"import datetime"
if you want to know the current date and time the code would be
"get = datetime.datetime.now()"
And the output is:
If you want to extract the information from date and time, then you can do it like
current_year = get.year
current_month = get.month
Example program;
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
The output is:
The github reference:
GitHub Code
https://gist.github.com/pinkpretty/577f188fa8bff563ed4d4802efebc5d6/edit
To manipulate date and time operations in python you have to import datetime module.
"import datetime"
if you want to know the current date and time the code would be
"get = datetime.datetime.now()"
And the output is:
If you want to extract the information from date and time, then you can do it like
current_year = get.year
current_month = get.month
Example program;
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
The output is:
The github reference:
GitHub Code
https://gist.github.com/pinkpretty/577f188fa8bff563ed4d4802efebc5d6/edit
No comments:
Post a Comment