How to get the first and last second in python using the DateTime module which means 00:00:01 and 23:59:59.
I want to get the six DateTime before today.
So, for example:
today is 12/10, and I want to get
12/9 00:00:01 and 23:59:59
…
12/4 00:00:01 and 23:59:59
Thank you very much.
Just use
datetime.time.minanddatetime.time.max:You can combine that with a
datetime.dateinstance to get a fulldatetime.datetimeinstance:To re-use an existing
datetime.datetimeinstance, use the.combine()method together with the.date()method on thedatetime.datetimeinstance to create a newdatetime.datetimeinstance:To get a series of dates, use
datetime.timedeltainstances to create offsets. A series of dates relative to today is then easy: