Home | My New Hugo Project

Python - getting seconds since midnight

2021-06-08

import datetime
now = datetime.datetime.now()
midnight = now.replace(hour=0, minute=0, second=0, microsecond=0)
seconds = (now - midnight).seconds

Can be made into an easy function.   And conversion to minutes and hours easy.