user1134478
user1134478

Reputation: 21

Jquery Date Picker culture issue

I am using jquery.ui.datepicker in asp.net mvc3 on windows 7.I changed my system date format as

Can anyone tell me how to solve this issue

Upvotes: 2

Views: 15361

Answers (2)

Daz
Daz

Reputation: 2873

Sangar82's answer is the most complete and correct (I upvoted it for that reason) but a quicker way of just setting the format without creating/downloading a localisation file is:

$(".dateinput").datepicker({dateFormat: 'dd/mm/yy'});

Upvotes: 6

Sangar82
Sangar82

Reputation: 5230

Try to use Datepicker Localization

The date picker is designed to allow localizations to be easily created and used. Many localizations are already available, and additional ones are welcomed.

The date picker plugin maintains a manager object, $.datepicker, that lets you register new localizations. This object maintains an array of localization settings indexed by language, with '' accessing the default (English) version: $.datepicker.regional['fr'].

A new localization should be created in a separate JavaScript file named ui.datepicker-.js. Within a document.ready event it should add a new entry into the $.datepicker.regional array, indexed by the language code.

http://docs.jquery.com/UI/Datepicker/Localization

Code:

$('selector').datepicker($.datepicker.regional['<language>']);

Example

$('.myinput').datepicker($.datepicker.regional['fr']);

When you download the Jquery UI you can find in the following folder the translation of datepicker on several languages (69 translations)

 development-bundle/ui/bundle/i18n 

Example of use:

<script type="text/javascript" src="js/ui/development-bundle/ui/bundle/i18n/ui.datepicker-fr.js"></script>

<script type="text/javascript">
    $(function() {
        $.datepicker.setDefaults($.datepicker.regional['fr']);
        $("#StartDate").datepicker();
    }); 
 </script>

Upvotes: 4

Related Questions