new date TO dd/mm/yyyy code example
Example 1: format date js
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today = new Date();
console.log(today.toLocaleDateString("en-US"));
console.log(today.toLocaleDateString("en-US", options));
date.toLocaleDateString("en-US", { day: 'numeric' })+ "-"+ date.toLocaleDateString("en-US", { month: 'short' })+ "-" + date.toLocaleDateString("en-US", { year: 'numeric' })
Example 2: js date format yyyy-mm-dd
yourDate.toISOString().split('T')[0]
Example 3: Convert a date to yyyy mm dd format
const formatYmd = date => date.toISOString().slice(0, 10);
formatYmd(new Date());