Python Check datetime With No/Zero/Midnight Time

August 10, 2019
import datetime

d = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0)

if d.time() == datetime.time():
    print('no time')

NOTE: if not d.time(): no longer works since Python 3.5+.

or

if d.hour == 0 and d.minute == 0 and d.second == 0 and d.microsecond == 0:
    print('no time')
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.