incrementDate¶
Increments a date/time by the specified date/time units.
Parameters¶
Combine the parameters as a JSON structure as input.
Parameter |
Mandatory/Optional |
Data Type |
Description |
|---|---|---|---|
startDate |
Mandatory |
String |
The date/time for incrementation. The format for this parameter must match the format specified in |
startDatePattern |
Mandatory |
String |
The format for |
endDatePattern |
Optional |
String |
The format of the string returned after incrementation, for example: yyyyMMdd HH:mm:ss.SSS. If not specified or if blank spaces are specified as the value, the format specified in |
addYears |
Optional |
String |
The number of years to add to |
addMonths |
Optional |
String |
The number of months to add to |
addDays |
Optional |
String |
The number of days to add to |
addHours |
Optional |
String |
The number of hours to add to |
addMinutes |
Optional |
String |
The number of minutes to add to |
addSeconds |
Optional |
String |
The number of seconds to add to |
addMilliSeconds |
Optional |
String |
The number of milliseconds to add to |
timezone |
Optional |
String |
The timezone for the returned date/time, such as GMT for Greenwich Mean Time. If not specified, GMT is used by default. |
locale |
Optional |
String |
|
Note
If startDate, startDatePattern, and endDatePattern are specified but the other optional incremental parameters are not specified, the startDate format will be converted from the startDatePattern to the endDatePattern format and returned as endDate.
Return Values¶
Value |
Data Type |
Description |
|---|---|---|
endDate |
String |
The date/time in the format specified in |
Samples¶
var format = tools.DateUtil.incrementDate({"startDate":"2021-04-13 10:23:55","startDatePattern":"yyyy-MM-dd hh:mm:ss","endDatePattern":"EEE yyyy-MM-dd hh:mm:ss","addYears":"1","addMonths":"1","addDays":"1","addHours":"1","addMinutes":"1","addSeconds":"1","addMilliSeconds":"111","timezone":"AGT","locale":"EN"});
return tools.resultBuilder.build(true, JSON.stringify(format));
Output
"Sat 2022-05-14 08:24:56"