Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrson83/1d3074b7f832785c8f443bf4b31252e4 to your computer and use it in GitHub Desktop.
Save jrson83/1d3074b7f832785c8f443bf4b31252e4 to your computer and use it in GitHub Desktop.
js date
var now = new Date(); // Date object
now.toDateString() // "Sun Jul 17 2016"
now.toLocaleDateString() // "2016/7/17"
now.toGMTString() // "Sun, 17 Jul 2016 03:16:49 GMT"
now.toISOString() // "2016-07-17T03:16:49.141Z"
now.toUTCString() // "Sun, 17 Jul 2016 03:16:49 GMT"
now.toLocaleTimeString() // "上午11:16:49"
now.toLocaleString() // "2016/7/17 上午11:16:49"
now.toString() // "Sun Jul 17 2016 11:16:49 GMT+0800 (台北標準時間)"
now.toTimeString() // "11:16:49 GMT+0800 (台北標準時間)"
now.toString(); // "Thu Apr 20 2017 22:19:38 GMT+0800 (台北標準時間)"
now.getTime() // time stamp
Date.now(); // time stamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment