Python Check datetime With No/Zero/Midnight Time

Aug 10, 2019
import datetimed = 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')

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.