Zest.

Python: Current date and time, formatted

A short, tested Python example for current date and time, formatted. Copy it and adjust the names and paths for your project.

Python
from datetime import datetime, timedelta, timezone

now = datetime.now()
print(now.strftime("%Y-%m-%d %H:%M:%S"))

utc = datetime.now(timezone.utc)
tomorrow = now + timedelta(days=1)

Find it in Zest

Search for “python current date and time, formatted” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Python examples

All Python examples