I am using a control for a popup calendar date picker. This uses a javascript function, SetText, to set the textbox to the given date. I can\'t change anything in the cale
You are using the Microsoft Ajax Framework, this framework defines a set of "client-side type extensions" which provide added functions or "extensions" to the JavaScript base types.
The Date Type Extensions is what you're looking for, specifically the Date.parseLocale function.
With this function you can parse a string, using a given format.
You can synchronize your server-side and client-side culture by setting the ScriptManager.EnableScriptGlobalization property to true, and use the Date.parseLocale function without specifying any format.
Give a look to this article:
If you control the backend, why not just send a timestamp and push it into Date
object?
As for formatting on the client side, since I was already using Dojo, I solved this problem by using dojo.date.locale.format
. It was completely painless.
Tutorial: http://docs.dojocampus.org/dojo/date/locale
API doc:
http://api.dojotoolkit.org/jsdoc/1.3/dojo.date.locale.format
Date format descriptions: http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns