Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 591
Federico Hoerth Avatar asked Feb 25 '23 08:02

Federico Hoerth


2 Answers

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" });
like image 132
Dolph Avatar answered Mar 04 '23 10:03

Dolph


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.

like image 22
plebksig Avatar answered Mar 04 '23 10:03

plebksig