Compartir a través de


Date.format Function

Formats a date by using the invariant (culture-independent) culture.

var a = dateVar.format(format);

Arguments

  • format
    A format string.

Return Value

A string that contains the formatted date value.

Exceptions

Exception type

Condition

Sys.ArgumentException

format is invalid.

Remarks

Use the format method to replace the date object value with a text representation based on the format parameter. The format method formats a date using the invariant (culture-independent) culture. The invariant culture is culture-insensitive.

Use the format method when the formatted value depends on a string comparison or a case-change operation. This makes sure that the behavior is consistent regardless of the culture settings of the system.

The invariant culture must be used only by processes that require culture-independent results, such as system services. Otherwise, the method can produce results that might be linguistically incorrect or culturally inappropriate.

The format method is not affected by the EnableScriptGlobalization attribute of the ScriptManager class.

For more information about date and time string formats, see Sys.CultureInfo Class.

See Also

Reference

Date Type Extensions

Other Resources

Language Reference