Skip to content

Instantly share code, notes, and snippets.

@hyeonseok
Created December 13, 2019 03:40
Show Gist options
  • Save hyeonseok/da88ca63b32cbcd4e3296c06ef096fbe to your computer and use it in GitHub Desktop.
Save hyeonseok/da88ca63b32cbcd4e3296c06ef096fbe to your computer and use it in GitHub Desktop.
// https://twitter.com/umaar/status/1205249225962995717
Object.getOwnPropertyNames(Date.prototype)
.filter(name => name.startsWith('to'))
.map(method => `${method}: ${(new Date())[method]()}`)
/*
0: "toUTCString: Fri, 13 Dec 2019 03:39:10 GMT"
1: "toLocaleString: 2019. 12. 13. 오후 12:39:10"
2: "toLocaleDateString: 2019. 12. 13."
3: "toLocaleTimeString: 오후 12:39:10"
4: "toDateString: Fri Dec 13 2019"
5: "toTimeString: 12:39:10 GMT+0900 (대한민국 표준시)"
6: "toISOString: 2019-12-13T03:39:10.263Z"
7: "toJSON: 2019-12-13T03:39:10.263Z"
8: "toSource: (new Date(1576208350263))"
9: "toString: Fri Dec 13 2019 12:39:10 GMT+0900 (대한민국 표준시)"
10: "toGMTString: Fri, 13 Dec 2019 03:39:10 GMT"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment