Search code examples
pythondateunixunix-timestamp

Time/Data Conversion to Unix


Im trying to convert a specific date to unix, but unfortunatelly something seems to be missing/wrong. Any help, will be highly appreciated.

releasedate='Jul 07 2022 02:00:00'
releasedate2 = datetime.strptime(releasedate, '%b-%d-%Y-%H:%M:%S')
unixdate = (releasedate2 - datetime(1970, 1, 1)).total_seconds()

Solution

  • You had used the wrong date and time format.

    You used: %b-%d-%Y-%H:%M:%S when the format of the date you have is %b %d %Y %H:%M:%S.