views:

65

answers:

2

Hi, I am using jquerry to display the calender to pick the date in my mvc application. i need to display the date in the converted format depending upon the browsers settings. if its newzeland, then i need to show the dateformat based on their language. how to do this?

below is my javascript

$(function() {
    $('#StartDate').datepicker({
    showOn: 'button', '/i/CalendarIcon.png', buttonImageOnly: true
    });

    $('#EndDate').datepicker({
        showOn: 'button', '/i/CalendarIcon.png', buttonImageOnly: true
    });
});
+1  A: 

The difficult part will be to detect the user's timezone. You can use the getTimezoneOffset method, but then you would need to run some code to concert the timezone to a location. The best and most reliable way is to ask your users about their location and date format preferences.

The datapicker widget supports localization. You can see a nice demo and of course you can modify the source to suit your needs.

kgiannakakis
Problem is, the user is not required to tell you where he is, what Browser he is using or even what Operating System he is using. These Infos can be hidden or spoofed. Although it is nice for the user to get some preferences predefined based on his location or time zone, I would not entirely rely on it. Instead ask the user to verify the preferences as suggested by kgiannakakis.
Mike
So u mean to say that to get culture specific dates, i need to ass few javascripts?. Only for those cultures, i will be able to see the formated date? am i right? tell me if my understanding is wrong.
Nimesh
See the localization datepicker demo to understand how you can change the date format depending on the locale. The idea is that you will ask the user somewhere about their preferences, store the selection somewhere and use it everywhere it is needed.
kgiannakakis
A: 

You might want to take a look at datejs

klaaspieter