Python fromtimestamp OSError

If you get this error and you’re not using an obviously wrong timestamp, check your units. fromtimestamp expects a timestamp in seconds, whereas it’s quite common to get timetstamps in milliseconds (e.g. I found this when trying to parse a timestamp produced from Moment.js in a calendar widget). Take the timestamp 1523443804214 – it’s 11th … Read more

how to convert a string to a Unix timestamp in javascript?

You can initialise a Date object and call getTime() to get it in unix form. It comes out in milliseconds so you’ll need to divide by 1000 to get it in seconds. (new Date(“2013/09/05 15:34:00”).getTime()/1000) It may have decimal bits so wrapping it in Math.round would clean that. Math.round(new Date(“2013/09/05 15:34:00”).getTime()/1000)