import pendulum try: print(pendulum.parse('{:0>2}-{:0>2}-{:0>2}'.format(2024, 9, 21))) except Exception as e: print(e)