Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The class is used to conduct operations on SimpleDateTime objects, for example, instantiating objects.

You can also use this class to calculate, change formats of the date-time or convert between the formats.

SimpleDateTime(dateTime)


Instantiates Use this constructor to instantiate a new SimpleDateTime object with the current or transferred date/time. The Specify the date and time value should be specified in the UTC timezone.

Parameter(s):

NameTypeMandatoryDefault Value
dateTimeStringN''


Example:

Code Block
languagejs
themeEclipse
titleSimpleDateTime
linenumberstrue
const nowDateTime = new SimpleDateTime();
//
const registrationDateTime = new SimpleDateTime(record.registration_datetime);
//
const yearStartDateTime = new SimpleDateTime('2019-01-01 00:00:00');
//
const laborDayStart

You can also use the values in relative format for the SimpleDateTime constructor. All formats are available in the Relative Formats article.

Code Block
languagejs
themeEclipse
titleSimpleDateTime
linenumberstrue
const yesterdayDatetime = new SimpleDateTime('2019-05-01yesterday');
ss.info(laborDayStartyesterdayDatetime.getValue());
// Info: 20192022-0502-0128 00:00:00

addDays(days)

This method is used to change the number of days in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds days to the object, the negative value diminishes the number of days.

Parameter(s):

NameTypeMandatoryDefault ValuedaysintegerYN

Return:

TypeDescriptionVoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titleaddDays
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addDays(3);
ss.info(registrationDateTime  

const tomorrowDatetime = new SimpleDateTime('tomorrow');
ss.info(tomorrowDatetime.getValue());
// Info: 2022-03-02 00:00:00

const yesterdayWorkdayDayStart = new SimpleDateTime('yesterday 06:30');
ss.info(yesterdayWorkdayDayStart.getValue());
// Info: 20192022-0102-0428 0806:12:10

addMonths(months)

This method is used to change the number of months in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds months to the object, the negative value diminishes the number of months.

Parameter(s):

NameTypeMandatoryDefault ValuemonthsIntegerYN

Return:

TypeDescriptionVoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titleaddMonths
linenumberstrue
const registrationDateTime30:00

const fistDayOfNextMonthStart = new SimpleDateTime('first day of next month 00:00');
ss.info(fistDayOfNextMonthStart.getValue());
// Info: 2022-04-01 00:00:00

const rangeStartDatetime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addMonths(-1);
`first day of ${monthName}`);
ss.info(registrationDateTimerangeStartDatetime .getValue());
// Info: 20182022-1202-01 0800:12:10

addSeconds(seconds)

00:00

const YEAR = 2022;
const MONTH = 2;
const monthDatetime = new SimpleDateTime(`${YEAR}-${String(MONTH).padStart(2, '0')}-02 00:00:00`);
const monthName = monthDatetime.getMonthUTC();
ss.info(monthName);
// Info: February


addDays(days)


This method is used to change the number of seconds days in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds seconds days to the object, the negative value diminishes the number of secondsdays.


Parameter(s):

NameTypeMandatoryDefault Value
secondsdaysIntegerintegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddSecondsaddDays
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addSecondsaddDays(36003);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-0104 0908:12:10
addWeeks

addMonths(

weeks

months)


This method is used to change the number of weeks months in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds weeks months to the object, the negative value diminishes the number of weeksmonths.


Parameter(s):

NameTypeMandatoryDefault Value
weeksmonthsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeksaddMonths
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addWeeksaddMonths(-1);
ss.info(registrationDateTime.getValue());
//Info: 20192018-12-01-08 08:12:10
addYears

addSeconds(

years

seconds)


This method is used to change the number of years seconds in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds years seconds to the object, the negative value diminishes the number of yearsseconds.


Parameter(s):

NameTypeMandatoryDefault Value
yearssecondsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddYearsaddSeconds
linenumberstrue
const contractStartDateTimeregistrationDateTime = new SimpleDateTime('2019-01-01 0008:0012:0010');
contractStartDateTimeregistrationDateTime.addYearsaddSeconds(13600);
ss.info(contractStartDateTimeregistrationDateTime.getValue());
//Info: 20202019-01-01 0009:0012:0010
after

addWeeks(

dateTime

weeks)


This method allows is used 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 FALSEchange the number of weeks in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds weeks to the object, the negative value diminishes the number of weeks.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeweeksSimpleDateTime objectIntegerYN


Return:

TypeDescription
Boolean
Void
The method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE
This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleafteraddWeeks
linenumberstrue
const startDateTimeregistrationDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:0012:0010');
const isStartLaterThanEnd = startDateTime.after(endDateTimeregistrationDateTime.addWeeks(1);
ss.info(isStartLaterThanEndregistrationDateTime.getValue());
//Info: false
before(dateTime
2019-01-08 08:12:10

addYears(years)


This method allows is used 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 falsechange the number of years in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds years to the object, the negative value diminishes the number of years.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeyearsSimpleDateTime objectIntegerYN


Return:

TypeDescription
Boolean
Void
The method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE
This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlebeforeaddYears
linenumberstrue
const startDateTimecontractStartDateTime = new SimpleDateTime('20182019-01-01 0700:5800:3500');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(isStartBeforeEndcontractStartDateTime.addYears(1);
ss.info(contractStartDateTime.getValue());
//Info: true
compareTo
2020-01-01 00:00:00

after(dateTime)


This method compares two date and time objects to determine whether they are equal and, if not, the method defines which goes after or before the other.allows 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(Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

Object's date is before the date specified in the parameter
TypeDescription
0Dates are equal.
1Object's date is after the date specified in the parameter.
BooleanThe method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE-1.


Example:

Code Block
languagejs
themeEclipse
titlecompareToafter
linenumberstrue
const firstDateTimestartDateTime = new SimpleDateTime('20192018-01-01 0807:0058:0035');
const secondDateTimeendDateTime = new SimpleDateTime('2019-01-01 08:1500:00');
const thirdDateTimeisStartAfterThanEnd = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(firstDateTime.compareTo(thirdDateTime))startDateTime.after(endDateTime);
ss.info(secondDateTime.compareTo(thirdDateTime));
ss.info(firstDateTime.compareTo(secondDateTime))isStartAfterThanEnd);
//Info: 0
//Info: 1
//Info: -1

equals(dateTime)

false

before(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 falseThis method compares a datetime with an existing value to determine whether they are equal or not.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return:

TypeDescription
BooleanThis The method returns TRUE if the date are equal; current date is earlier than the date specified by the parameter; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleequalsbefore
linenumberstrue
const firstDateTimestartDateTime = new SimpleDateTime('2018-01-01 0807:0058:0035');
const secondDateTimeendDateTime = new SimpleDateTime('20182019-01-01 08:1500:00');
const thirdDateTimeisStartBeforeEnd = new SimpleDateTime('2018-01-01 08:00:00');

ss.info(firstDateTime.equals(secondDateTime))startDateTime.before(endDateTime);
ss.info(thirdDateTime.equals(firstDateTime)isStartBeforeEnd);
//Info: false
//Info: true
getDate

compareTo(dateTime)


This method returns the date saved by the SimpleDateTime object in the system time zone.

Return:

TypeDescriptionStringThe date in the default timezone.

compares two date and time objects to determine whether they are equal and, if not, the method defines which goes after or before the other.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
0Dates are equal.
1Object's date is after the date specified in the parameter.
-1Object's date is before the date specified in the parameter.


Example:

Code Block
languagejs
themeEclipse
titlecompareTo

Example:

Code Block
languagejs
themeEclipse
titlegetDate
linenumberstrue
const startDateTimebegin = new SimpleDateTime('2019-0104-01 08:0015:00');
ss.info(startDateTime.getDate());
//Info: 2019-01-01

getDayOfMonthLocalTime()

This method returns the day of the month saved by the SimpleDateTime object in the current user's time zone.

Return:

TypeDescriptionIntegerThe day of the month value.
const end = new SimpleDateTime('2019-05-01 01:00:00');

ss.info(begin.compareTo(end));   // -1
ss.info(end.compareTo(begin));   // 1
ss.info(begin.compareTo(begin)); // 0

equals(dateTime)


This method compares a datetime with an existing value to determine whether they are equal or not.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return:

TypeDescription
BooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE.


Example:

Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimeequals
linenumberstrue
const holidayDateTimefirstDateTime = new SimpleDateTime('20192018-01-0701 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTime());
//Info: 7

getDayOfMonthUTC()

This method returns the day of the month saved by the SimpleDateTime object in the UTC time zone.

Return:

TypeDescriptionIntegerThe day of the month value.

Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTime const secondDateTime = new SimpleDateTime('2018-01-01 08:15:00');
const thirdDateTime = new SimpleDateTime('20192018-01-0701 08:00:00');

ss.info(holidayDateTime.getDayOfMonthUTC(firstDateTime.equals(secondDateTime));
ss.info(thirdDateTime.equals(firstDateTime));
//Info: 7
getDayOfWeekLocalTime
false
//Info: true

getDate()


This method returns the day of the week date saved by the SimpleDateTime object in the current user's system time zone.


Return:

TypeDescription
StringThe
day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 

Example:

date in the default timezone.


Example:

Code Block
languagejs
themeEclipse
titlegetDate
Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTime
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekLocalTimegetDate()); 
// Mon
getDayOfWeekUTC
Info: 2019-01-01

getDayOfMonthLocalTime()


This method returns the day of the week month saved by the SimpleDateTime object in the system current user's time zone.


Return:

TypeDescription
String
IntegerThe day of
week
the month value.
Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 

Example:


Example:

Code Block
Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTCgetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekUTCgetDayOfMonthLocalTime());
//Info: Mon7
getDaysInMonthLocalTime

getDayOfMonthUTC()


This method returns the number day of days in the month saved by the SimpleDateTime object in the current user's UTC time zone.


Return:

TypeDescription
IntegerThe
number
day of
days
the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthLocalTimegetDaysofMonthsLocalTime
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDaysInMonthLocalTimegetDayOfMonthUTC());
//Info: 317
getDaysInMonthUTC

getDayOfWeekLocalTime()


This method returns the number day of days in the month week saved by the SimpleDateTime object in the system current user's time zone.


Return:

TypeDescription
Integer
StringThe
number
day of
days value.
week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetDayOfWeekLocalTime
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDaysInMonthUTCgetDayOfWeekLocalTime());
 //Info: 31Mon
getDisplayValue

getDayOfWeekUTC()


This method returns the date and time value in the current user's display format and timezonethe day of the week saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
StringThe
date and time
day of week value.
Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetDayOfWeekUTC
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDisplayValuegetDayOfWeekUTC()); 
// current user's timezone is Europe/Moscow
//Info: 2019-01-01 11:00:00 
getErrorMsg()
Info: Mon

getDaysInMonthLocalTime()


This method returns the error message if number of days in the month saved by the SimpleDateTime object was incorrectin the current user's time zone.


Return:

TypeDescription
String
IntegerThe
error message
number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetDaysInMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-zz01-01 08:00:00');
ss.errorinfo(startDateTime.getErrorMsggetDaysInMonthLocalTime());
//ErrorInfo: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()

31

getDaysInMonthUTC()


This method returns the number of days in the month This method returns the date saved by the SimpleDateTime object in the current user's system time zone.


Return:

TypeDescription
String
IntegerThe
date in the user's time zone
number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDategetDaysInMonthUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getLocalDategetDaysInMonthUTC());
//Info: 2019-01-01
getLocalTime
31

getDisplayValue()


This method returns the date and time saved value in a SimpleDateTime object in the current user's time zone display format and timezone.


Return:

TypeDescription
SimpleDateTime
StringThe
time in the user's time zone
date and time value.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimegetDisplayValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info( "My local time is " + time.getByFormat('h:i:s'startDateTime.getDisplayValue());
 //Info: Mycurrent localuser's timetimezone is 02Europe/Moscow
//Info: 2019-01-01 11:00:00 
getMonthLocalTime

getErrorMsg()


This method returns the month saved by SimpleDateTime object in the current user's time zoneerror message if the SimpleDateTime object was incorrect.


Return:

TypeDescription
StringThe
value of the month
error message.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTimegetErrorMsg
linenumberstrue
const startDateTime = new SimpleDateTime('2019-12zz-3101 2308:4500:00');
ss.infoerror(startDateTime.getMonthLocalTimegetErrorMsg());
//InfoError: January

getMonthUTC()

DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


This method returns the date saved by the This method returns the month saved by SimpleDateTime object in the system current user's time zone.


Return:

TypeDescription
StringThe
value of the month
date in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthUTCgetLocalDate
linenumberstrue
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getMonthUTCgetLocalDate());
//Info: December
getNumericValue
2019-01-01

getLocalTime()


This method returns the Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00time saved in a SimpleDateTime object in the current user's time zone .


Return:

TypeDescription
Integer
SimpleDateTimeThe
Unix timestamp value
time in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetNumericValuegetLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info(startDateTime.getNumericValue( "My local time is " + time.getByFormat('h:i:s'));
//Info: 1546329600
getTime
My local time is 02:00:00

getMonthLocalTime()


This method returns a the month saved by SimpleDateTime object that shows the piece of time of the SimpleDateTime objectin the current user's time zone.


Return:

TypeDescription
SimpleDateTime
StringThe
Unix duration stamp
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetTimegetMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
const time = ss.info(startDateTime.getTimegetMonthLocalTime());
ss.info(time.getByFormat('h:i:s'));
//Info: 11:01:00
getValue
//Info: January

getMonthUTC()


This method returns the date and time value in the internal formatmonth saved by SimpleDateTime object in the system time zone.


Return:

TypeDescription
null | string
StringThe
date and time
value
in
of the
internal format
month.


Example:

Code Block
languagejs
themeEclipse
titlegetValuegetMonthUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getValuegetMonthUTC()); 
// 2019-01-01 08:00:00
getWeekOfYearLocalTime
Info: December

getNumericValue()


This method returns the week's number saved by the SimpleDateTime object in the current user's time zoneUnix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.


Return:

TypeDescription
IntegerThe
number of the current week
Unix timestamp value.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTimegetNumericValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getWeekOfYearLocalTimegetNumericValue());
//Info: 11546329600
getWeekOfYearUTC

getTime()


This method returns the number of the week saved by a SimpleDateTime object that shows the piece of time of the SimpleDateTime object in the system time zone.


Return:

TypeDescription
Integer
SimpleDateTimeThe
number of the current week
Unix duration stamp.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTCgetTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
const time = startDateTime.getTime();
ss.info(startDateTimetime.getWeekOfYearUTC(getByFormat('h:i:s'));
//Info: 1
getYearLocalTime
11:01:00

getValue()


This method returns the year saved by the SimpleDateTime object in the current user's time zonedate and time value in the internal format.


Return:

TypeDescription
IntegerFour-digit year value
null | stringThe date and time value in the internal format.


Example:

Code Block
languagejs
themeEclipse
titlegetYearLocalTimegetValue
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(holidayDateTimestartDateTime.getYearLocalTimegetValue());
 //Info: 2020
getYearUTC
 2019-01-01 08:00:00

getWeekOfYearLocalTime()


This method returns the year saved week's number saved by the SimpleDateTime object in the system current user's time zone.


Return:

TypeDescription
Integer
Four-digit year value
The number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetYearUTCgetWeekOfYearLocalTime
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(holidayDateTimestartDateTime.getYearUTCgetWeekOfYearLocalTime()); 
//Info: 20191
isValid

getWeekOfYearUTC()


This method allows to determine if a specified value is a valid date and timereturns the number of the week saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
Boolean
IntegerThe
method returns TRUE if the value is a valid date and time; otherwise, it returns
number of the current week.


Example:

Code Block
languagejs
themeEclipse
titleisValidgetWeekOfYearUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
startDateTime.setValue("2011-aa-01 00:00:00");
ss.info(startDateTime.isValidgetWeekOfYearUTC());
//Info: false1
setValue

getYearLocalTime(

dateTime

)


This method

is intended to define the date and time value within

returns the year saved by the SimpleDateTime object in the current user's time zone.

Parameter(s):

Name


Return:

Type
Mandatory
Description
Default ValuedateTimeA string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss.YNdateTimeA SimpleDateTime object.YNdateTimeA JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00.YN

Return:

TypeDescriptionVoidThis method does not return a value.
IntegerFour-digit year value.


Example:

Code Block
languagejs
themeEclipse
titlegetYearLocalTime
linenumberstrue
const holidayDateTime

Example:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(startDateTime.getValue());
ss.info(holidayDateTime.getYearLocalTime());
//Info: 2020-01-01 12:00:00
subtract(first, second

getYearUTC()


This method returns the amount of time between two SimpleDateTime values. Also, it can subtract the amount of time from the current SimpleDateTime object.

Parameter(s):

NameTypeMandatoryDefault Valuefirst

SimpleDateTime Object

YNfirst

SimpleTime Object

YNfirst

Number (seconds)

YNsecondSimpleDateTime ObjectNNULLsecondSimpleTime ObjectNNULLsecondNumber (seconds)NNULL

the year saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
IntegerFour-digit year value.


Example

Return:

TypeSimpleDuration object

Example:

Code Block
languagejs
themeEclipse
titlesubtract #1getYearUTC
linenumberstrue
const plannedDateTimeholidayDateTime = new SimpleDateTime(current.actual_end_datetime); // '2019-11-08 20:00'2019-12-31 23:45:00'
const actualDateTime = new SimpleDateTime(current.planned_end_datetime);
ss.info(holidayDateTime.getYearUTC()); 
//Info: '2019-11-08 20:06:28'

if (actualDateTime.after(plannedDateTime)) {
  const duraction = actualDateTime.subtract(plannedDateTime, actualDateTime); // 388
  if (duraction.getDurationSeconds() > 300) { // more than 5 minutes
    ss.eventQueue('notify.change_manager', current, current.assigned_user.getValue('manager'));
  }
}
Same example without using of the subtract
2019

isValid()


This method allows to determine if a specified value is a valid date and time.


Return:

TypeDescription
BooleanThe method returns TRUE if the value is a valid date and time; otherwise, it returns .


Example:

Code Block
languagejs
themeEclipse
titleisValid
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue('2011-aa-01 00:00:00');
ss.info(startDateTime.isValid());
//Info: false

setValue(dateTime)


This method is intended to define the date and time value within the SimpleDateTime object.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeA string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss.YN
dateTimeA SimpleDateTime object.YN
dateTimeA JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00.YN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(startDateTime.getValue());
//Info: 2020-01-01 12:00:00

subtract(first, second)


This method returns the amount of time between two SimpleDateTime values. Also, it can subtract the amount of time from the current SimpleDateTime object.

Note

Displaying of the final value using the getDisplayValue() method returns it considering the current user' timezone, unlike the getValue() method. It returns data only in UTC timezone.


Parameter(s):

NameTypeMandatoryDefault Value
first

SimpleDateTime Object

YN
secondSimpleDateTime ObjectNNULL


Return:

Type
SimpleDuration object


Example:

Code Block
languagejs
themeEclipse
titlesubtract #1
linenumberstrue
const plannedDateTimestartDatetime = new SimpleDateTime(current.actual_end_datetime); // '2019-11-08 20:00:00');
const actualDateTime = new SimpleDateTime(current.planned_end_datetime); // endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const 
if (actualDateTime.after(plannedDateTime)) {
  const duraction = plannedDateTime.getNumericValue() - actualDateTime.getNumericValue(); // 388
  if (duraction > 300) { // more than 5 minutes
    ss.eventQueuediffDuration = new SimpleDateTime().subtract(startDatetime, endDatetime); 
ss.info(diffDuration.getDurationSeconds());
// Info: 388

Same example without using of the subtract:

Code Block
languagejs
themeEclipse
linenumberstrue
const startDatetime = new SimpleDateTime('2019-11-08 20:00:00');
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffSeconds = endDatetime.getNumericValue() - startDatetime.getNumericValue(); 
ss.info(diffSeconds);
// Info: 388('notify.change_manager', current, current.assigned_user.getValue('manager'));
  }
}


Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const plannedDateTimedatetime = new SimpleDateTime('2020-08-28 09:00:00');
plannedDateTimedatetime.subtract(3600);
ss.info(plannedDateTimedatetime.getDisplayValuegetValue());
//Info: 2020-08-28 1108:00:00

Same example without using of the subtract:

Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const plannedDateTimedatetime = new SimpleDateTime('2020-08-28 09:00:00');
plannedDateTimedatetime.addSeconds(-3600);
ss.info(plannedDateTimedatetime.getDisplayValuegetValue());
//Info: 2020-08-28 1108:00:00


Table of Contents
absoluteUrltrue