user6552641
user6552641

Reputation:

Javascript DatePicker format year in 2 digits

I'm using datepicker. The problem I'm having is that the year is giving me 4 digits.

$.datepicker.setDefaults({
    dateFormat: 'dd-mm-yy'
});

Shouldn't yy give me only 2 digits?

How do I get 2 digits on the year instead of 4?

Upvotes: 1

Views: 805

Answers (2)

handle
handle

Reputation: 6329

This is about JQuery. Docs: http://api.jqueryui.com/datepicker/

y - year (two digit)
yy - year (four digit)

So:

$.datepicker.setDefaults({
    dateFormat: 'dd-mm-y'
});

Upvotes: 2

James
James

Reputation: 1446

Use single y

$.datepicker.setDefaults({
    dateFormat: 'dd-mm-y'
});

Source: https://api.jqueryui.com/datepicker/

Upvotes: 1

Related Questions