The toString() method returns a text representation of the date/time value.
Declaration
DayPilot.Date.toString();
Returns the string representation created using toStringSortable() - in ISO8601 format.
DayPilot.Date.toString(pattern [,locale]);
Returns the string formatted using the pattern (and locale).
Parameters
- pattern (string) - specifies the format pattern; if not specified, the output will use ISO 8601 format ("2020-12-31T00:00:00")
- locale (string or DayPilot.Locale) - the locale that will be used to format the output string; a string specifies a registered locale (see DayPilot.Locale.register() method)
Pattern Elements
- yyyy - full year: 2013
- MMMM - full month name string: January
- MMM - short month name string: Jan
- MM - two-digit month number: 01
- M - month number: 1
- dddd - day of week string: Monday
- ddd - short day of week string: Mo
- dd - two-digit day of month number: 09
- d - day of month number: 9
- HH - two-digit hours, 24-hour clock: 23
- H - hours, 24-hour clock: 23
- hh - two-digit hours, 12-hour clock: 11
- h - hours, 12-hour clock: 11
- tt - AM/PM string
- mm - two-digit minutes: 08
- m - minutes: 8
- ss - two-digit seconds: 07
- s - seconds: 7
Example patterns:
- "MM/dd/yyyy": 12/31/2013
- "dd.MM.yyyy": 31.12.2013
When locale is specified, the output uses the day names and month names defined by the locale (for "dddd" and "MMMM").
Examples
Using a custom format pattern:
> new DayPilot.Date("2013-12-31T13:30:00").toString("MM/dd/yyyy");
"12/31/2013"
Using a custom format pattern and locale:
> new DayPilot.Date("2013-12-31T13:30:00").toString("dddd d MMMM yyyy", "es-es");
"martes 31 diciembre 2013"