Skip to content

Instantly share code, notes, and snippets.

@oahehc
Created July 29, 2019 09:32
Show Gist options
  • Save oahehc/79cc9b82022d5db58dc80179abb830d6 to your computer and use it in GitHub Desktop.
Save oahehc/79cc9b82022d5db58dc80179abb830d6 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