Versions Compared

Key

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

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):

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 = new SimpleDateTime('2019-05-01'); // 2019-05-01 00:00:00
setValue

addDays(

dateTime

days)


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):

NameTypeMandatoryDefault Value
dateTimeA string in the local time zone 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:

daysintegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetValueaddDays
linenumberstrue
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
addSeconds

addMonths(

seconds

months)


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):

NameTypeMandatoryDefault Value
seconds
monthsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddSecondsaddMonths
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addSecondsaddMonths(3600-1);
ss.info(registrationDateTime.getValue()); // 20192018-0112-01 0908:12:10
addDays

addSeconds(

days

seconds)


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):

NameTypeMandatoryDefault Value
days
seconds
integer
IntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddDaysaddSeconds
linenumberstrue
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):

NameTypeMandatoryDefault Value
weeksIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeks
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addWeeks(1);
ss.info(registrationDateTime.getValue()); // 2019-01-08 08:12:10
addMonths

addYears(

months

years)


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):

NameTypeMandatoryDefault Value
monthsyearsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddMonthsaddYears
linenumberstrue
const registrationDateTimecontractStartDateTime = new SimpleDateTime('2019-01-01 0800:1200:1000');
registrationDateTimecontractStartDateTime.addMonthsaddYears(-1);
ss.info(registrationDateTimecontractStartDateTime.getValue()); // 20182020-1201-01 0800:1200:1000
addYears

after(

years

dateTime)


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):

NameTypeMandatoryDefault Value
yearsdateTimeIntegerSimpleDateTime objectYN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titleaddYearsafter
linenumberstrue
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
after
false

before(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):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
BooleanThe method returns TRUE if the current date is later earlier than the date specified by the parameter; otherwise, returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleafterbefore
linenumberstrue
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
before

compareTo(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):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

The method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE
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 parameterBoolean.


Example:

Code Block
languagejs
themeEclipse
titlebeforecompareTo
linenumberstrue
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
compareTo

equals(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):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


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.
BooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titlecompareToequals
linenumberstrue
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):

NameTypeMandatoryDefault ValuedateTimeSimpleDateTime object.YN

Return:

TypeDescriptionBooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE.
true

getDate()


This method returns the date stored by the SimpleDateTime object, showed in the system time zone.


Return:

TypeDescription
StringThe date in the default timezone.


Example:

Code Block
languagejs
themeEclipse
titleequalsgetDate
linenumberstrue
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:

TypeDescription
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
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()

7

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:

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


Example:

Code Block
languagejs
themeEclipse
titlegetValuegetDaysofMonthsLocalTime
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getValuegetDayOfMonthUTC()); // 2019-01-01 08:00:00
getDisplayValue
7

getDayOfWeekLocalTime()


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:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetDayOfWeekLocalTime
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDisplayValuegetDayOfWeekLocalTime()) ; // 2019-01-01 11:00:00
getDate
 // Mon

getDayOfWeekUTC()


This method returns the date stored day of the week saved by the SimpleDateTime object, showed in the system time zone.

Return:

TypeDescriptionStringThe date in the default timezone.

, showed in the system time zone.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDategetDayOfWeekUTC
linenumberstrue
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:

TypeDescription
IntegerThe number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDaysInMonthLocalTime()); // 31
getDayOfMonthLocalTime

getDaysInMonthUTC()


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:

TypeDescription
IntegerThe
day
number of
the month
days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimegetDaysInMonthUTC
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfMonthLocalTimegetDaysInMonthUTC()); // 731
getDayOfMonthUTC

getDisplayValue()


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:

TypeDescription
Integer
StringThe
day of the month
date and time value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimegetDisplayValue
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfMonthUTCgetDisplayValue()) ; // 7
getDayOfWeekLocalTime
2019-01-01 11:00:00

getErrorMsg()


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:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTimegetErrorMsg
linenumberstrue
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:

TypeDescription
StringThe
day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 
date in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTCgetLocalDate
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekUTCgetLocalDate()); // Mon
getDaysInMonthUTC
2019-01-01

getLocalTime()


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:

TypeDescription
Integer
SimpleDateTimeThe
number of days value
time in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetLocalTime
linenumberstrue
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
isValid
My 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:

TypeDescription
Boolean
StringThe
method returns TRUE if the value is a valid date and time; otherwise, it returns
value of the month.


Example:

Code Block
languagejs
themeEclipse
titleisValidgetMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
startDateTime.setValue("2011-aa-01 00:00:00");
ss.info(startDateTime.isValidgetMonthLocalTime());  // falseJanuary
getErrorMsg

getMonthUTC()


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:

TypeDescription
StringThe
error message
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetMonthUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-zz12-0131 0823:0045:00');
ss.info(startDateTime.getErrorMsggetMonthUTC());  // DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given
getLocalDate
December

getNumericValue()


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:

TypeDescription
String
IntegerThe
date in the user's time zone
timestamp value.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDategetNumericValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getLocalDategetNumericValue()); // 2019-01-01
getLocalTime
1546329600

getTime()


This method returns a SimpleDateTime object that shows the piece of time in the user's time zoneof the SimpleDateTime object.


Return:

TypeDescription
SimpleDateTime
The time in the user's time zone
The Unix duration stamp.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimegetTime
linenumberstrue
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
getMonthLocalTime

getValue()


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:

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


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTimegetValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getMonthLocalTimegetValue()); // January
getMonthUTC
2019-01-01 08:00:00

getWeekOfYearLocalTime()


This method returns the number of the month week saved by the SimpleDateTime object, showed in the system user's time-zone.


Return:

TypeDescription
String
IntegerThe
value
number of the
month
current week.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthUTCgetWeekOfYearLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTime.getMonthUTCgetWeekOfYearLocalTime()); // December1
getNumericValue

getWeekOfYearUTC()


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:

TypeDescription
IntegerThe
timestamp value
number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetNumericValuegetWeekOfYearUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getNumericValuegetWeekOfYearUTC()); // 15463296001
getTime

getYearLocalTime()


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:

TypeDescription
SimpleDateTimeThe Unix duration stamp
IntegerFour-digit year value.


Example:

Code Block
languagejs
themeEclipse
titlegetTimegetYearLocalTime
linenumberstrue
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
getWeekOfYearLocalTime
2020

getYearUTC()


This method returns the number of the week year saved by the SimpleDateTime object, showed in the user's system time - zone.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTimegetYearUTC
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTimeholidayDateTime.getWeekOfYearLocalTimegetYearUTC()); // 12019
getWeekOfYearUTC

isValid()


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:

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


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTCisValid
linenumberstrue
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
startDateTime.setValue("2011-aa-01 00:00:00");
ss.info(startDateTime.getWeekOfYearUTCisValid());  // 1false
getYearLocalTime

setValue(dateTime)


This method returns the year saved by the SimpleDateTime object, showed in the user's time zone.

Return:

TypeDescriptionIntegerFour-digit year value.

sets the date and time of the SimpleDateTime object.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeA string in the local time zone 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


Example:

Code Block
languagejs
themeEclipse
titlegetYearLocalTime
linenumberstrue
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:

TypeDescription
IntegerFour-digit year
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlegetYearUTCsetValue
linenumberstrue
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):

NameTypeMandatoryDefault Value
first

SimpleDateTime Object

YN
first

SimpleTime Object

YN
first

Number (milliseconds)

YN
secondSimpleDateTime ObjectNNULL
secondSimpleTime ObjectNNULL
secondNumber (milliseconds)NNULL


Return:

Type
SimpleDuration object


Example:

Code Block
languagejs
themeEclipse
titlesubtract
linenumberstrue
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


Table of Contents
absoluteUrltrue
classfixedPosition