date tolocalestring code example
Example 1: m06 javascript tolocalestring returning for june
const d = new Date('2010-08-05')
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d)
const mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d)
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d)
console.log(`${da}-${mo}-${ye}`)
Example 2: how to get date using tolocaledatestring
const date=new Date();
const options - {weekday:'long',year:'numeric',month:'long',day:'numeric'};
let today=today.toLocaleDatestring("en-IN",options);
Example 3: toLocaleDateString() options
new Date("1983-March-25").toLocaleDateString('fr-CA', { year: 'numeric', month: '2-digit', day: '2-digit' })
'03/25/1983'
Example 4: toLocalString
Data.prototype.toLocaleString()