Displaying proper date format depending on culture

后端 未结 8 1307
感情败类
感情败类 2021-01-06 06:40

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

8条回答
  •  独厮守ぢ
    2021-01-06 07:14

    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.

    • Locale is detected automatically or can be set arbitrarily.
    • Shorthand format options (e.g.: long short)
    • Data selectors (e.g.: time, date)
    • Ability to specify an arbitrary date/time pattern (probably not application to this application, but still useful).

    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

提交回复
热议问题