Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Date Localization

I'm working with an ASP.NET app with localization and globalization. I'm having some difficulty understanding how to get the Date() function in javascript to work properly given the user's environment. My user base is split between Mexico (spanish) and the US (english). Since the Mexico date format is dd/mm/yyyy and the english format is mm/dd/yyyy, the standard Date(strDate) javascript constructor does not work for me.

Does anyone know the best way to handle globalization/localization of a javascript Date value? I have some business rules to enforce like dateA must be 90 days prior to dateB and dateB cannot exceed today.

like image 474
RSolberg Avatar asked Feb 17 '09 02:02

RSolberg


1 Answers

Take a look at datejs, it handles localization very nicely. It comes with a lot of globalization setups. You just load the globalization setup of your current CultureInfo and datejs takes care of the rest.

like image 130
Mauricio Scheffer Avatar answered Nov 10 '22 10:11

Mauricio Scheffer