michaelminter
3/14/2013 - 5:23 PM

Create a millisecond timestamp in Javascript

Create a millisecond timestamp in Javascript

// create timestamp with milliseconds for unique id
var date = new Date();
var components = [
    date.getYear(),
    date.getMonth(),
    date.getDate(),
    date.getHours(),
    date.getMinutes(),
    date.getSeconds(),
    date.getMilliseconds()
];
var timestamp = components.join("");