This class provides methods for performing operations on SimpleDateTime objects, such as instantiating objects, for example.
You can also use this class to perform date-time operations, such as calculations, formatting or converting between date-time formats.
SimpleDateTime(dateTime)
Instantiates a new SimpleDateTime object with the current or transferred date/time.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | String | N | '' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | SimpleDateTime |
---|
linenumbers | true |
---|
|
const nowDateTime = new SimpleDateTime();
//
const registrationDateTime = new SimpleDateTime(record.registration_datetime);
//
const yearStartDateTime = new SimpleDateTime('2019-01-01 00:00:00');
//
const laborDayStart = new SimpleDateTime('2019-05-01'); // 2019-05-01 00:00:00 |
setValueaddDays(
dateTimedays)
This method sets the date and time of the SimpleDateTime objectadds a specified number of days to the current SimpleDateTime object. The negative value of the parameter will subtract the days.
The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the days using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | A string in the local time zone and the internal format of yyyy-MM-dd HH:mm:ss. | Y | N |
dateTime | A SimpleDateTime object, | Y | N |
dateTime | A JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00. | Y | N |
Return:
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setValueaddDays |
---|
linenumbers | true |
---|
|
const startDateTimeregistrationDateTime = new SimpleDateTime('2019-01-01 08:0012:0010');
startDateTimeregistrationDateTime.setValue('2020-01-01 12:00:00'addDays(3);
ss.info(startDateTimeregistrationDateTime.getValue()); // 20202019-01-0104 08:12:00:0010 |
addSecondsaddMonths(
secondsmonths)
This method adds a specified number of seconds months to the current SimpleDateTime object.
Parameter(s):
. The negative value of the parameter will subtract the months.
The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the months using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
seconds
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addSecondsaddMonths |
---|
linenumbers | true |
---|
|
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addSecondsaddMonths(3600-1);
ss.info(registrationDateTime.getValue()); // 20192018-0112-01 0908:12:10 |
addDaysaddSeconds(
daysseconds)
This method adds a specified number of days seconds to the current SimpleDateTime object. The negative value of the parameter will subtract the days.
The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the days using local date and time values.
.
Parameter(s)Parameter(s):
Name | Type | Mandatory | Default Value |
---|
daysinteger
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addDaysaddSeconds |
---|
linenumbers | true |
---|
|
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addDaysaddSeconds(33600);
ss.info(registrationDateTime.getValue()); // 2019-01-0401 0809:12:10 |
addWeeks(weeks)
This method adds a specified number of weeks to the current SimpleDateTime object. The negative value of the parameter will subtract the weeks.
The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the weeks using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
weeks | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeks |
---|
linenumbers | true |
---|
|
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addWeeks(1);
ss.info(registrationDateTime.getValue()); // 2019-01-08 08:12:10 |
addMonthsaddYears(
monthsyears)
This method adds a specified number of months years to the current SimpleDateTime object. The negative value of the parameter will subtract the monthsyears.
The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the months years using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
monthsyears | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addMonthsaddYears |
---|
linenumbers | true |
---|
|
const registrationDateTimecontractStartDateTime = new SimpleDateTime('2019-01-01 0800:1200:1000');
registrationDateTimecontractStartDateTime.addMonthsaddYears(-1);
ss.info(registrationDateTimecontractStartDateTime.getValue()); // 20182020-1201-01 0800:1200:1000 |
addYearsafter(
yearsdateTime)
This method adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the years using local date and time valuesallows to compare the date specified by the ‘dateTime‘ parameter with the current date. The method returns TRUE, if the current date is after the specified; otherwise returns FALSE.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
yearsdateTime | IntegerSimpleDateTime object | Y | N |
Return:
VoidThis method does not return a valueThe method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addYearsafter |
---|
linenumbers | true |
---|
|
const contractStartDateTimestartDateTime = new SimpleDateTime('20192018-01-01 0007:0058:0035');
contractStartDateTime.addYears(1const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartLaterThanEnd = startDateTime.after(endDateTime);
ss.info(contractStartDateTime.getValue()isStartLaterThanEnd); // 2020-01-01 00:00:00 |
afterbefore(dateTime)
This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date. The
The method returns TRUE, if the current date is after before the specified; otherwise returns FALSEfalse.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
Boolean | The method returns TRUE if the current date is later earlier than the date specified by the parameter; otherwise, returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | afterbefore |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartLaterThanEndisStartBeforeEnd = startDateTime.afterbefore(endDateTime);
ss.info(isStartLaterThanEndisStartBeforeEnd); // falsetrue |
beforecompareTo(dateTime)
This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date.The method returns TRUE, if the current date is before the specified; otherwise returns falsecompares two date and time objects to determine whether they are equivalent or not.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
0 | Dates are equal |
1 | Object's date is after the date specified in the parameter. |
-1 | Object's date is before the date specified in the parameter | Boolean | The method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | beforecompareTo |
---|
linenumbers | true |
---|
|
const startDateTimefirstDateTime = new SimpleDateTime('20182019-01-01 0708:5800:3500');
const endDateTimesecondDateTime = new SimpleDateTime('20192018-01-01 08:00:00');
const isStartBeforeEndthirdDateTime = new startDateTime.before(endDateTimeSimpleDateTime('2018-01-01 08:00:00');
ss.info(isStartBeforeEndthirdDateTime.compareTo(secondDateTime )); // 0
ss.info(firstDateTime.compareTo(secondDateTime)); // 1
ss.info(secondDateTime.compareTo(firstDateTime)); // true-1 |
compareToequals(dateTime)
This method compares two date and time objects to determine whether they are equivalent or not.a datetime with an existing value if they are equal.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object. | Y | N |
Return:
Type | Description |
---|
0 | Dates are equal |
1 | Object's date is after the date specified in the parameter. |
-1 | Object's date is before the date specified in the parameter. |
Boolean | This method returns TRUE if the date are equal; otherwise, it returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | compareToequals |
---|
linenumbers | true |
---|
|
const firstDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const secondDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const thirdDateTime = new SimpleDateTime('2018-01-01 08:00:00');
ss.info(thirdDateTimefirstDateTime.compareToequals(secondDateTime )); // 0false
ss.info(firstDateTimethirdDateTime.compareToequals(secondDateTime)); // 1
ss.info(secondDateTime.compareTo(firstDateTime)); // -1 |
equals(dateTime)
This method compares a datetime with an existing value if they are equal.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object. | Y | N |
Return:
Type | Description |
---|
Boolean | This method returns TRUE if the date are equal; otherwise, it returns FALSE. |
getDate()
This method returns the date stored by the SimpleDateTime object, showed in the system time zone.
Return:
Type | Description |
---|
String | The date in the default timezone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | equalsgetDate |
---|
linenumbers | true |
---|
|
const firstDateTimestartDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDate()); // 2019-01-01 |
getDayOfMonthLocalTime()
This method returns the day of the month saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|
Integer | The day of the month value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTimeconst secondDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const thirdDateTime = new SimpleDateTime('20182019-01-0107 08:00:00');
ss.info(firstDateTimeholidayDateTime.equalsgetDayOfMonthLocalTime(secondDateTime)); // false
ss.info(thirdDateTime.equals(secondDateTime)); // true |
getValue()
getDayOfMonthUTC()
This method returns the day of the month saved by the SimpleDateTime object, showed in the UTC time zoneThis method gets the date and time value in the internal format.
Return:
null | string date and time value in the internal format
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getValuegetDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getValuegetDayOfMonthUTC()); // 2019-01-01 08:00:00 |
getDisplayValuegetDayOfWeekLocalTime()
This method gets the date and time value in the current user's display format and timezonereturns the day of the week saved by the SimpleDateTime object, showed in the user's time zone.
Return:
date and time value.day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDisplayValuegetDayOfWeekLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDisplayValuegetDayOfWeekLocalTime()) ; // 2019-01-01 11:00:00 |
getDategetDayOfWeekUTC()
This method returns the date stored day of the week saved by the SimpleDateTime object, showed in the system time zone.
Return:
Type | Description |
---|
String | The date in the default timezone. |
, showed in the system time zone.
Return:
Type | Description |
---|
String | The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDategetDayOfWeekUTC |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDategetDayOfWeekUTC()); // 2019-01-01Mon |
getDaysInMonthLocalTime()
This method returns the number of days in the month saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|
Integer | The number of days value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDaysInMonthLocalTime()); // 31 |
getDayOfMonthLocalTimegetDaysInMonthUTC()
This method returns the day number of days in the month saved by the SimpleDateTime object, showed in the user's system time zone.
Return:
Type | Description |
---|
Integer | The |
day the month
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTimegetDaysInMonthUTC |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfMonthLocalTimegetDaysInMonthUTC()); // 731 |
getDayOfMonthUTCgetDisplayValue()
This method returns the day of the month saved by the SimpleDateTime object, showed in the UTC time zonegets the date and time value in the current user's display format and timezone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTimegetDisplayValue |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfMonthUTCgetDisplayValue()) ; // 7 |
getDayOfWeekLocalTimegetErrorMsg()
This method returns the day of the week saved by the SimpleDateTime object, showed in the user's time zonemethod gets the error message if the SimpleDateTime object was incorrect.
Return:
day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekLocalTimegetErrorMsg |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-zz-01-07 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekLocalTimegetErrorMsg()); // Mon |
getDayOfWeekUTC DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given |
getLocalDate()
This method returns the day of the week saved date stored by the SimpleDateTime object, showed in the system user's time zone.
Return:
day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' date in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekUTCgetLocalDate |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekUTCgetLocalDate()); // Mon |
getDaysInMonthUTCgetLocalTime()
This method returns the number of days in the month saved by the SimpleDateTime object, showed in the system a SimpleDateTime object that shows the time in the user's time zone.
Return:
Integer number of days valuetime in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthUTCgetLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info(startDateTime.getDaysInMonthUTC( "My local time is " + time.getByFormat('h:m:s')); // 31 |
isValidMy local time is 02:01:00 |
getMonthLocalTime()
This method allows to determine if a specified value is a valid date and time. returns the month saved by SimpleDateTime object, showed in the current user's time zone.
Return:
Boolean method returns TRUE if the value is a valid date and time; otherwise, it returns
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isValidgetMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
startDateTime.setValue("2011-aa-01 00:00:00");
ss.info(startDateTime.isValidgetMonthLocalTime()); // falseJanuary |
getErrorMsggetMonthUTC()
This method gets the error message if the SimpleDateTime object was incorrectreturns the month saved by SimpleDateTime object, showed in the system time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getErrorMsggetMonthUTC |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-zz12-0131 0823:0045:00');
ss.info(startDateTime.getErrorMsggetMonthUTC()); // DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given |
getLocalDategetNumericValue()
This method returns the date stored by the SimpleDateTime object, showed in the user's time zonegets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00.
Return:
String date in the user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalDategetNumericValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getLocalDategetNumericValue()); // 2019-01-01 |
getLocalTimegetTime()
This method returns a SimpleDateTime object that shows the piece of time in the user's time zoneof the SimpleDateTime object.
Return:
Type | Description |
---|
SimpleDateTime |
The time in the user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalTimegetTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getLocalTimegetTime();
ss.info( "My local time is " + time.getByFormat('h:m:s')); // My local time is 0211:01:00 |
getMonthLocalTimegetValue()
This method returns the month saved by SimpleDateTime object, showed in the current user's time zonegets the date and time value in the internal format.
Return:
String | The value of the monthnull | string | The date and time value in the internal format. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthLocalTimegetValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getMonthLocalTimegetValue()); // January |
getMonthUTCgetWeekOfYearLocalTime()
This method returns the number of the month week saved by the SimpleDateTime object, showed in the system user's time-zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthUTCgetWeekOfYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTime.getMonthUTCgetWeekOfYearLocalTime()); // December1 |
getNumericValuegetWeekOfYearUTC()
This method gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00returns the number of the week saved by the SimpleDateTime object, showed in the system time-zone.
Return:
Type | Description |
---|
Integer | The |
timestamp valuenumber of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getNumericValuegetWeekOfYearUTC |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getNumericValuegetWeekOfYearUTC()); // 15463296001 |
getTimegetYearLocalTime()
This method returns a the year saved by the SimpleDateTime object that shows the piece of time of the SimpleDateTime object, showed in the user's time zone.
Return:
SimpleDateTime | The Unix duration stampInteger | Four-digit year value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getTimegetYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
const time = startDateTime.getTime();
ss.info(timeholidayDateTime.getByFormat('h:m:s'getYearLocalTime()); // 11:01:00 |
getWeekOfYearLocalTimegetYearUTC()
This method returns the number of the week year saved by the SimpleDateTime object, showed in the user's system time - zone.
Return:
The number of the current week
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearLocalTimegetYearUTC |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTimeholidayDateTime.getWeekOfYearLocalTimegetYearUTC()); // 12019 |
getWeekOfYearUTCisValid()
This method returns the number of the week saved by the SimpleDateTime object, showed in the system time-zone.allows to determine if a specified value is a valid date and time.
Return:
Integer number of the current weekmethod returns TRUE if the value is a valid date and time; otherwise, it returns . |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearUTCisValid |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
startDateTime.setValue("2011-aa-01 00:00:00");
ss.info(startDateTime.getWeekOfYearUTCisValid()); // 1false |
getYearLocalTimesetValue(dateTime)
This method returns the year saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|
Integer | Four-digit year value. |
sets the date and time of the SimpleDateTime object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | A string in the local time zone and the internal format of yyyy-MM-dd HH:mm:ss. | Y | N |
dateTime | A SimpleDateTime object, | Y | N |
dateTime | A JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00. | Y | N |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(holidayDateTime.getYearLocalTime()); // 2020 |
getYearUTC()
This method returns the year saved by the SimpleDateTime object, showed in the system time zone.
Return:
Integer | Four-digit year Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearUTCsetValue |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45-01-01 08:00:00');
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(holidayDateTimestartDateTime.getYearUTCgetValue()); // 20192020-01-01 12:00:00 |
subtract(first, second)
This method gets the duration between to SimpleDateTime values. Also, it can subtract the amount of time from the current SimpleDateTime object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
first | SimpleDateTime Object | Y | N |
first | SimpleTime Object | Y | N |
first | Number (milliseconds) | Y | N |
second | SimpleDateTime Object | N | NULL |
second | SimpleTime Object | N | NULL |
second | Number (milliseconds) | N | NULL |
Return:
Type |
---|
SimpleDuration object |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime("2019-01-01 08:00:00");
const periodTime = new SimpleTime();
periodTime.setValue("00:00:20");
startDateTime.subtract(periodTime);
const afterSutractDateTime = startDateTime.getTime();
ss.info(afterSutractDateTime.getByFormat('h:m:s')); // 01:12:40 |