A Cheatsheet of Date Strings in JavaScript

const date = new Date();

date.getDate() // 31  
date.getDay() // 4  
date.getFullYear() // 2017  
date.getHours() // 15  
date.getMilliseconds() // 321  
date.getMinutes() // 1  
date.getMonth() // 7  
date.getSeconds() // 53  
date.getTime() // 1504188113321  
date.getTimezoneOffset() // -60  
date.getUTCDate() // 31  
date.getUTCDay() // 4  
date.getUTCFullYear() // 2017  
date.getUTCHours() // 14  
date.getUTCMilliseconds() // 321  
date.getUTCMinutes() // 1  
date.getUTCMonth() // 7  
date.getUTCSeconds() // 53  
date.getYear() // 117  
date.toDateString() // Thu Aug 31 2017  
date.toGMTString() // Thu, 31 Aug 2017 14:01:53 GMT  
date.toISOString() // 2017-08-31T14:01:53.321Z  
date.toJSON() // 2017-08-31T14:01:53.321Z  
date.toLocaleDateString() // 31/08/2017  
date.toLocaleString() // 31/08/2017, 15:01:53  
date.toLocaleTimeString() // 15:01:53  
date.toString() // Thu Aug 31 2017 15:01:53 GMT+0100 (BST)  
date.toTimeString() // 15:01:53 GMT+0100 (BST)  
date.toUTCString() // Thu, 31 Aug 2017 14:01:53 GMT  
date.valueOf() // 1504188113321  

Daniel Li

Full-stack Web Developer in Hong Kong. Founder of Brew.

Hong Kong http://danyll.com