Skip to content

Instantly share code, notes, and snippets.

@yukidarake
Created December 9, 2011 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukidarake/1449692 to your computer and use it in GitHub Desktop.
Save yukidarake/1449692 to your computer and use it in GitHub Desktop.
時間をyyyy-MM-dd hh:mm:ss.SSSとして表示
function now() {
var d = new Date(),
yyyy = d.getYear() + 1900,
MM = ('0' + (d.getMonth() + 1)).slice(-2),
dd = ('0' + d.getDate()).slice(-2),
hh = ('0' + d.getHours()).slice(-2),
mm = ('0' + d.getMinutes()).slice(-2),
ss = ('0' + d.getSeconds()).slice(-2),
SSS = ('00' + d.getMilliseconds()).slice(-3);
return yyyy + '-' + MM + '-' + dd + ' ' + hh + ':' + mm + ':' + ss + '.' + SSS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment