The following piece of code shows you how to get the YYYY-MM-DD formatted string from a Javascript Date Object.
// GET CURRENT DATE
var date = new Date();
// GET YYYY, MM AND DD FROM THE DATE OBJECT
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth()+1).toString();
var dd = date.getDate().toString();
// CONVERT mm AND dd INTO chars
var mmChars = mm.split('');
var ddChars = dd.split('');
// CONCAT THE STRINGS IN YYYY-MM-DD FORMAT
var datestring = yyyy + '-' + (mmChars[1]?mm:"0"+mmChars[0]) + '-' + (ddChars[1]?dd:"0"+ddChars[0]);
Done =)
Reference: StackOverflow – Get String in YYYYMMDD format from JS date object?

Thanx, this helped.
LikeLike
Good to know that it helps. =D
LikeLike
The output is of string type.Is there any way to convert string to date object with the dd/MM/yyyy format and output after format change is of date type and not of string,
LikeLike
Please refer to Javascript – Create a date object from a date string.
LikeLike
It’s great. There is some free online tools, like javascript date time formatter, it’s easy to use.
LikeLike
Thanks for your suggestion~ =)
LikeLike
Thank you very much…. this is very helpful for me….
LikeLike
you are welcome~ =)
LikeLike
var date = (new Date()).toISOString().split(‘T’)[0];
LikeLike