Date and time in Python

from datetime import datetime


# from / to string
s1 = "2019-08-29T12-29-32"
fmt = "%Y-%m-%dT%H-%M-%S"
dt = datetime.strptime(s1, fmt)
s2 = dt.strftime(fmt)
assert s1 == s2


def now():
    """Timezone-aware now"""
    from datetime import datetime, timezone

    return datetime.utcnow().replace(tzinfo=timezone.utc)