Skip to content

Instantly share code, notes, and snippets.

@Krakenus
Created August 14, 2020 13:55
Show Gist options
  • Save Krakenus/eddee4f7ee2ddc3c6bfe48adb32182bb to your computer and use it in GitHub Desktop.
Save Krakenus/eddee4f7ee2ddc3c6bfe48adb32182bb to your computer and use it in GitHub Desktop.
Get seconds remaining to midnight from current time
def seconds_to_midnight() -> int:
now = datetime.now()
midnight = now + timedelta(days=1)
midnight = midnight.replace(hour=0, minute=0, second=0, microsecond=0)
return (midnight - now).seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment