DayPilot.Date.toString

The toString() method returns a text representation of the date/time value.

Declaration

DayPilot.Date.toString();

Returns the string representation created using toStringSortable() in ISO 8601 format.

DayPilot.Date.toString(pattern [,locale]);

Returns the string formatted using the specified pattern and locale.

Parameters

  • pattern (string) - specifies the format pattern; if not specified, the output uses 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())

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

Notes

When locale is specified, the output uses the day names and month names defined by that locale for textual pattern elements such as dddd and MMMM.

This formatting syntax is also used by multiple DayPilot configuration properties that display dates in headers and moving indicators.

Example

Using a custom format pattern:

const date = new DayPilot.Date("2013-12-31T13:30:00");
const value = date.toString("MM/dd/yyyy");  // "12/31/2013"

Using a custom format pattern and locale:

const date = new DayPilot.Date("2013-12-31T13:30:00");
const value = date.toString("dddd d MMMM yyyy", "es-es");  // "martes 31 diciembre 2013"

See Also

DayPilot.Date.toStringSortable

DayPilot.Locale Class

DayPilot.Locale.register()

DayPilot.Date Class

Header Date Format [doc.daypilot.org]

Time Header Rows [doc.daypilot.org]

Event Moving Indicators [doc.daypilot.org]

Time Header Rows [doc.daypilot.org]

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript