Michael
Michael

Reputation: 51

overlapping date format in jquery

I'm trying to set the datepicker up with a format like this

$("#date").datepicker({
dateFormat: 'date_yyyy-mm-dd'
});

I want it to output "date_2017-08-22" but the issue is that it outputs "22ate_20172017-08-22". Why is it doing that?

Upvotes: 1

Views: 51

Answers (1)

Purple Haze
Purple Haze

Reputation: 550

The d in date is considered as a day hence the 22 at the beginning, as for the years each 'yy' represents a year if you put 'yyyy' it will print two years as it did in you example, you can use single quotes to put literal text as follows:

$("#date").datepicker({
dateFormat: "'date_'yy-mm-dd"
});

You can check more documentation here, good luck.

Upvotes: 2

Related Questions