Displaying proper date format depending on culture

后端 未结 8 1338
感情败类
感情败类 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 06:54

    As you are using ASP.NET then you may also be using ASP.NET Ajax. If so, there are two properties on the ScriptManager that are of use to you:

    EnableScriptLocalization - Gets or sets a value that indicates whether the ScriptManager control renders localized versions of script files.

    EnableScriptGlobalization - Gets or sets a value that indicates whether the ScriptManager control renders script that supports parsing and formatting of culture-specific information.

    
    

    When you enable both of these (set to true) then ASP.NET Ajax extenders etc. should automatically be localised into the culture specified in web.config:

    
      
          
      
    
    

    For instance, setting this will localise the AjaxControlToolkit Calendar into your specificed culture.

    Even if you are NOT using ASP.NET Ajax adding a ScriptManager and enabling localisation will give you a useful javascript variable called __cultureInfo that contains a JSON array of localised formate, such as currencies, dates etc.

    "CalendarType":1,"Eras":[1],"TwoDigitYearMax":2029,"IsReadOnly":true},"DateSeparator":"/","FirstDayOfWeek":1,"CalendarWeekRule":0,"FullDateTimePattern":"dd MMMM yyyy HH:mm:ss","LongDatePattern":"dd MMMM yyyy","LongTimePattern":"HH:mm:ss","MonthDayPattern":"dd MMMM","PMDesignator":"PM","RFC1123Pattern":"ffffd, dd MMM yyyy HH\u0027:\u0027mm\u0027:\u0027ss etc....
    

提交回复
热议问题