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 |
---|---|
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.
The following format strings are supported: D, d, T, t, F, f, M, m, s, Y, y. For more information about format strings, see Standard Date and Time Format Strings. For more information about globalizing dates, see Walkthrough: Globalizing a Date by Using Client Script.
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
Concepts
Standard Date and Time Format Strings