4

everybody... I was wondering how I could format the a date in the datepicker 'd de MM de yy' in stead of 'dd/MM/yy'.

(suppose the date is 21/01/2011 (in spanish) .. so: $("#element").datepicker({ dateFormat:'d de MM de yy' });

It will output : 21 21e Enero 21e yy

The question is.. is there an escape character so I can format the date? Thanks, sorry for my English, hope you guys understand

3 Answers 3

7

You can escape any plain text characters:

$("#element").datepicker({ dateFormat:'d \\d\\e MM \\d\\e yy' });

You may also be able to escape plain text using single quotes:

$("#element").datepicker({ dateFormat:"d 'de' MM 'de' yy" });
Sign up to request clarification or add additional context in comments.

Comments

1

You can define the datepicker on startup, then just use a class to attach it later. I've defined a datepicker like this:

$(".date-pick").datepicker($.extend({}, $.datepicker.regional["no"], {showStatus: true, defaultDate: +1, minDate: 1, maxDate: 365,  dateFormat: "dd.mm.yy", showOn: "both", buttonImage: "../images/shop/calendar.png", buttonImageOnly: true}));

Should be explained in the options/documentation.

Comments

0

Try this for date format and year till the current year

$('#element').datepicker({
        dateFormat: "dd M yy",
        changeMonth: true,
        changeYear: true,
        yearRange: "1920:+nn",
        maxDate: 0
    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.