JavaScript unixtime problem <p>I get the time from the database in Unix format.</p> <p>It looks like this: console.log (time); Result: 1300709088000</p> <p>Now I want to reformat it and pick out only the time, I found this: <a href="http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript">Convert a Unix timestamp to time in Javascript</a></p> <p>That did not work as I want. The time I get is this:</p> <pre><code>1300709088000 9:0:0 1300709252000 6:33:20 1300709316000 0:20:0 1300709358000 12:0:0 1300709530000 11:46:40 </code></pre> <p>It is very wrong times when I know that times are quite different. How can I fix it?</p> <pre><code> console.log(time); var date = new Date(time*1000); // hours part from the timestamp var hours = date.getHours(); // minutes part from the timestamp var minutes = date.getMinutes(); // seconds part from the timestamp var seconds = date.getSeconds(); // will display time in 10:30:23 format var formattedTime = hours + ':' + minutes + ':' + seconds; console.log(formattedTime); </code></pre>