Date
const options = { year: 'numeric', month: 'short', day: 'numeric' };const date = new Date()date.toLocaleDateString(undefined, options) // default localedate.toLocaleDateString('en-US', options) // Oct 24, 2019date.toLocaleDateString('zh-CN', options) // 2019年10月24日
NOTE: Date.toLocaleDateString
Time
const options = { hour: '2-digit', minute: '2-digit' }const date = new Date()date.toLocaleTimeString() // "1:09:07 PM" - Depending on System Locale Settingsdate.toLocaleString(undefined, options) // "01:09 PM"
NOTE: Date.toLocaleTimeString
Date and Time
const options = { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }const date = new Date()date.toLocaleDateString() // "3/28/2020" - Depending on System Locale Settingsdate.toLocaleString(undefined, options) // "Mar 28, 2020, 01:09 PM"
NOTE: Date.toLocaleString