by @kodeazy

How to convert timestamp to datetimeformat in python?

Home » Python » How to convert timestamp to datetimeformat in python?
  • With the help of time.strftime function we can convert timestamp into date time format.
  • To use time.strftime we have to import time.
  • Below is the sample example.

    import time
    ts=time.time()
    time.strftime("%D %H:%M", time.localtime(ts))

    Output:

    '03/30/22 17:28'