I am trying to convert long to date:
class timeStamp(object): def getDateTime(self,longDate): myNumber = float(longDate) return str(datetime.datetime.fromtimestamp(time.ctime(myNumber)).strftime('%Y-%m-%d %H:%M:%S'))
But I have a strange error:
File "./index.py", line 104, in getDateTime return str(datetime.datetime.fromtimestamp(time.ctime(myNumber)).strftime('%Y-%m-%d %H:%M:%S')) TypeError: a float is required
Why does he complain when I explicitly throw it in a float? The Unix long timestamp is stored as long in mysql.
source share