Adrian Diaz2,742 Points
When will this method ever be useful?
can't we just use what we learned in the previous lesson to enter in a specific date and time, when will we need to convert the date and time from string format?
Jennifer NordellTreehouse Staff
Hi, Adrian Diaz! Being able to make a new
datetime object from a string is very useful. I know that it may not seem like it now. But Python, besides just being a generic purpose scripting language and good for data analysis, can also be used for web development.
Imagine a scenario where we have a web form and we ask users for their birthday. Anything they type in that input field will be a string naturally. Now we can format that how we wish, and validate it etc, but it's still a string. But when we save it to the database, we want to save it as a
datetime object. Maybe a week before their birthday we want to send out a coupon for our services or some other small birthday bonus. There are all kinds of calculations you can do when the date is a
datetime object as opposed to just a string.
Hope this helps!