Partager via


Date.localeFormat Function

Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object.

var formattedDate = dateVar.localeFormat(format);

Arguments

  • format
    A format string.

Return Value

A string that contains the formatted date value.

Exceptions

Exception type

Condition

Sys.ArgumentException

format was invalid.

Remarks

Use the localeFormat function to replace the date object value with a text representation based on the format parameter. The localeFormat method provides the date based on a specific culture value (locale). The culture value is also used to display information for specific language and country combinations.

To format a date object value by using the localeFormat function, set the EnableScriptGlobalization property of the ScriptManager control to true. You must also modify settings in the Web.config file so that the culture attribute of the globalization section is set to auto.

For more information about cultures and locales, see ASP.NET Globalization and Localization and the CultureInfo documentation. For more information about date and time string formats, see Sys.CultureInfo Class.

Note

This type does not support the locale values th-TH, ar-SA, dv-MV, prs-AF, and ps-AF.

See Also

Tasks

Walkthrough: Globalizing a Date by Using Client Script

Reference

CultureInfo

Date Type Extensions

Other Resources

ASP.NET Globalization and Localization

Language Reference