Federico Hoerth
Federico Hoerth

Reputation: 275

Date Formatting in jquery datepicker

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

Upvotes: 4

Views: 2359

Answers (3)

ahmed sharief
ahmed sharief

Reputation: 83

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
    });

Upvotes: 0

plebksig
plebksig

Reputation: 535

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.

Upvotes: 1

Dolph
Dolph

Reputation: 50650

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" });

Upvotes: 7

Related Questions