Thank you for visiting. This time, I'm going to use Datime mainly in the Python library, so please take a look to the end if you like. Immediately, the reason I studied the module called Datetime and posted it to Qiita this time is because I used the module called Datetime in my business. At first I didn't understand it at all, but I was able to read and understand the book ** Self-study Python **. I will post this on the link so please have a look.
datetime stands for date and time. Modules are parts, so please remember that = parts that represent the date and time. First, I will introduce the main modules of datetime.
Mold | Overview |
---|---|
datetime | date/Time value |
date | Date value |
time | Time value |
timezone | Time zone information |
timedelta | Time interval(Because I couldn't read kanji) |
** Here are some example sentences. ** **
import datetime #Module import
#①
print(datetime.datetime.today()) #output(module.date/Time value.today)=つまりtodayのdate/時刻をoutput
print(datetime.date.today()) #output(module.Date value.today)=つまりtodayの日付をoutput
#②
#It will be a little longer. Conclusion = Output to know the time zone.
#③
print(datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=0))))
#Output (module.date/Time value.now(module.Time zone information(module.Time interval(Time = how many hours))))
Output result=================================================
#(* This is an example because the dates and times are not all the same.)
#① 2020-08-10 22:08:11.888987
#② 2020-08-10
#③ 2020-08-10 22:08:11.888987+00:00
=======================================================
Recommended Posts