Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Last active December 14, 2015 23:09
Show Gist options
  • Select an option

  • Save michaelminter/5163293 to your computer and use it in GitHub Desktop.

Select an option

Save michaelminter/5163293 to your computer and use it in GitHub Desktop.
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("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment