![]()  | 
  
     v1.3.0.0
    
   | 
 
Date prototype extension methods
Public Member Functions | |
| Date | clone () | 
| Date | addSeconds (number seconds) | 
| Date | addMinutes (number seconds) | 
| Date | addHours (number seconds) | 
| Date | addDays (number days) | 
| Date | addMonths (number months) | 
| Date | addYears (number years) | 
| Date | compareToDate (Date otherDate) | 
| string | format (string format) | 
| string | toLocaleDateString (Locale locale, string format) | 
| string | toLocaleString (Locale locale, string format) | 
| string | toLocaleTimeString (Locale locale, string format) | 
Static Public Member Functions | |
| Date | fromLocaleDateString (Locale locale, string dateString,< string|number > format) | 
| Date | fromLocaleString (Locale locale, string dateTimeString,< string|number > format) | 
| Date | fromLocaleTimeString (Locale locale, string timeString,< string|number > format) | 
| Date addSeconds | ( | number | seconds | ) | 
Adds seconds to current date and returns new Date object. seconds can be negative to subtract from current time and can be in any integer value range. 
| Date addMinutes | ( | number | seconds | ) | 
Adds minutes to current date and returns new Date object. minutes can be negative to subtract from current time and can be in any integer value range. 
| Date addHours | ( | number | seconds | ) | 
Adds hours to current date and returns new Date object. hours can be negative to subtract from current time and can be in any integer value range. 
| Date addDays | ( | number | days | ) | 
Adds days to current date and returns new Date object. days can be negative to subtract from current date and can be in any integer value range. 
| Date addMonths | ( | number | months | ) | 
Adds months to current date and returns new Date object. months can be negative to subtract from current date and can be in any integer value range. 
| Date addYears | ( | number | years | ) | 
Adds years to current date and returns new Date object. years can be negative to subtract from current date and can be in any integer value range. 
Compares this Date to otherDate based only on the year, month and day parts, ignoring time part. Returns -1 if otherDate is earlier than this date, 0 if the dates match, and 1 if otherDate is later than this date. 
| string format | ( | string | format | ) | 
Formats this date according the specified .NET-style format string. 
This function emulates the .NET DateTime.ToString() method.
For example:
See formatting string reference at https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#table-of-format-specifiers
Converts the date string dateString to a Date object using given locale and format. 
| locale | A Locale object, obtained with the global locale() method.  | 
| dateString | The input string to parse | 
| format | A Locale format constant or string format specifier. | 
If format is not specified, Locale.LongFormat will be used. 
 If locale is not specified, the default locale will be used.
The following example shows a datetime being parsed from a datetime string in a certain format using the default locale
Converts the date string dateTimeString to a Date object using given locale and format. 
| locale | A Locale object, obtained with the global locale() method.  | 
| dateTimeString | The input string to parse | 
| format | A Locale format constant or string format specifier. | 
If format is not specified, Locale.LongFormat will be used. 
 If locale is not specified, the default locale will be used.
The following example shows a datetime being parsed from a datetime string in a certain format using the default locale
Converts the date string timeString to a Date object using given locale and format. 
| locale | A Locale object, obtained with the global locale() method.  | 
| timeString | The input string to parse | 
| format | A Locale format constant or string format specifier. | 
If format is not specified, Locale.LongFormat will be used. 
 If locale is not specified, the default locale will be used.
The following example shows a datetime being parsed from a datetime string in a certain format using the German locale:
| string toLocaleDateString | ( | Locale | locale, | 
| string | format | ||
| ) | 
Converts the Date to a string containing the date suitable for the specified locale in the specified format. 
| locale | A Locale object, obtained with the global locale() method.  | 
| format | A Locale format constant or string format specifier. | 
If format is not specified, Locale.LongFormat will be used. 
 If locale is not specified, the default 'locale()` will be used. 
The following example shows the current date formatted for the German locale:
| string toLocaleString | ( | Locale | locale, | 
| string | format | ||
| ) | 
Converts the Date to a string containing the date and time suitable for the specified locale in the specified format. 
| locale | A Locale object, obtained with the global locale() method.  | 
| format | A Locale format constant or string format specifier. | 
If format is not specified, Locale.LongFormat will be used. If locale is not specified, the default 'locale()` will be used.
The following example shows the current date and time formatted for the German locale:
| string toLocaleTimeString | ( | Locale | locale, | 
| string | format | ||
| ) | 
Converts the Date to a string containing the time suitable for the specified locale in the specified format. 
| locale | A Locale object, obtained with the global locale() method.  | 
| format | A Locale format constant or string format specifier. | 
If format is not specified, Locale.LongFormat will be used. If locale is not specified, the default locale will be used.
The following example shows the current date and time formatted for the German locale: