次の方法で共有


Date.parseLocale Function

Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object.

var a = Date.parseLocale(value, formats);

Arguments

  • value
    A locale-specific string that represents a date.

  • formats
    (Optional) An array of custom formats.

Return Value

If value is a valid string representation of a date, an object of type Date; otherwise, null.

Exceptions

Exception type

Condition

Sys.ArgumentException

(Debug) formats contains an invalid format.

Remarks

Use the pareseLocale function to create an object of type Date from a string. If you provide no custom formats, this function uses the Sys.CultureInfo.CurrentCulture property to determine the culture value.

To create a date from a locale-specific string that uses the current culture, 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.

Note

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

See Also

Reference

Date Type Extensions

Other Resources

Language Reference