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 date and 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');
addDays

setValue(

days

dateTime)


This method adds 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 valuessets the date and time of the SimpleDateTime object.


Parameter(s):

NameTypeMandatoryDefault Value
daysintegerYN

Return:

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


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddDayssetValue
linenumberstrue
const registrationDateTimestartDateTime = new SimpleDateTime('2019-01-01 08:1200:1000');
registrationDateTimestartDateTime.addDays(3setValue('2020-01-01 12:00:00');
ss.info(registrationDateTimestartDateTime.getValue());  // 20192020-01-0401 0812:1200:1000
addMonths

addSeconds(

months

seconds)


This method adds a specified number of months seconds to the current SimpleDateTime object. 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):


Parameter(s):

Name
Name
TypeMandatoryDefault Value
months
secondsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddMonthsaddSeconds
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addMonthsaddSeconds(-13600);
ss.info(registrationDateTime.getValue()); // 20182019-1201-01 0809:12:10
addSeconds

addDays(

seconds

days)


This method adds a specified number of seconds 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(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()); // 2019-01-0104 0908: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
addYears

addMonths(

years

months)


This method adds a specified number of years months to the current SimpleDateTime object. The negative value of the parameter will subtract the yearsmonths.

The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the years months using local date and time values.


Parameter(s):

NameTypeMandatoryDefault Value
years
monthsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddYearsaddMonths
linenumberstrue
const contractStartDateTimeregistrationDateTime = new SimpleDateTime('2019-01-01 0008:0012:0010');
contractStartDateTimeregistrationDateTime.addYearsaddMonths(-1);
ss.info(contractStartDateTimeregistrationDateTime.getValue()); // 20202018-0112-01 0008:0012:0010
after

addYears(

dateTime

years)


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 after the specified; otherwise returns FALSEadds 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 values.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeyearsSimpleDateTime 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
titleafteraddYears
linenumberstrue
const startDateTimecontractStartDateTime = new SimpleDateTime('20182019-01-01 0700:5800:3500');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartLaterThanEnd = startDateTime.after(endDateTime);
ss.info(isStartLaterThanEndcontractStartDateTime.addYears(1);
ss.info(contractStartDateTime.getValue()); // false
before
2020-01-01 00:00:00

after(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 before after the specified; otherwise returns falseFALSE.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlebeforeafter
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartBeforeEndisStartLaterThanEnd = startDateTime.beforeafter(endDateTime);
ss.info(isStartBeforeEndisStartLaterThanEnd); // truefalse
compareTo

before(dateTime)


This method compares two date and time objects to determine whether they are equivalent or notallows 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 false.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlecompareTobefore
linenumberstrue
const firstDateTimestartDateTime = new SimpleDateTime('20192018-01-01 0807:0058:0035');
const secondDateTimeendDateTime = new SimpleDateTime('20182019-01-01 08:00:00');
const thirdDateTimeisStartBeforeEnd = new SimpleDateTime('2018-01-01 08:00:00'startDateTime.before(endDateTime);


ssss.info(thirdDateTime.compareTo(secondDateTime ))isStartBeforeEnd); // 0
ss.info(firstDateTime.compareTo(secondDateTime)); // 1
ss.info(secondDateTime.compareTo(firstDateTime)); // -1
equals(
true

compareTo(dateTime)


This method compares a datetime with an existing value if they are equaltwo date and time objects to determine whether they are equivalent or not.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return:

This method returns TRUE if the date are equal; otherwise, it returns FALSE
TypeDescriptionBoolean
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
titleequalscompareTo
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(firstDateTimethirdDateTime.equalscompareTo(secondDateTime )); // false0
ss.info(thirdDateTimefirstDateTime.equalscompareTo(secondDateTime)); // true

getDate()

This method returns the date stored by the SimpleDateTime object, showed in the system time zone.
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 Value
dateTimeSimpleDateTime object.YN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDateequals
linenumberstrue
const startDateTimefirstDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDate()); // 2019-01-01
getDaysInMonthLocalTime
const secondDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const thirdDateTime = new SimpleDateTime('2018-01-01 08:00:00');

ss.info(firstDateTime.equals(secondDateTime)); // false
ss.info(thirdDateTime.equals(secondDateTime)); // true

getValue()


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

Return:

gets the date and time value in the internal format.


Return:

TypeDescription
Integer
null | stringThe
number of days value
date and time value in the internal format.


Example:

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

getDisplayValue()


This method returns the day of the month saved by the SimpleDateTime object, showed in the user's 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.getDayOfMonthLocalTimegetDisplayValue()) ; // 7
getDayOfMonthUTC
2019-01-01 11:00:00

getDate()


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


Return:

TypeDescription
Integer
StringThe
day of the month value
date in the default timezone.


Example:

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

getDaysInMonthLocalTime()


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


Return:

TypeDescription
String
IntegerThe
day
number of
week
days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTimegetDaysInMonthLocalTime
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekLocalTimegetDaysInMonthLocalTime()); // Mon31
getDayOfWeekUTC


getDayOfMonthLocalTime()


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


Return:

TypeDescription
String
IntegerThe day of
week
the month value.


Example:

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

getDayOfMonthUTC()


This method returns the number day of days in the month saved by the SimpleDateTime object, showed in the system UTC time zone.


Return:

TypeDescription
IntegerThe
number
day of
days
the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetDaysofMonthsLocalTime
linenumberstrue
var simple_date_timeconst holidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(simple_date_time.getDaysInMonthUTCholidayDateTime.getDayOfMonthUTC() ); // 317
getDisplayValue

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
day of week value.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetDayOfWeekLocalTime
linenumberstrue
var simple_date_timeconst holidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info( simple_date_time.getDisplayValueholidayDateTime.getDayOfWeekLocalTime() ) ; // 2019-01-01 11:00:00
getErrorMsg
Mon

getDayOfWeekUTC()


This method gets the error message if returns the day of the week saved by the SimpleDateTime object was incorrect, showed in the system time zone.


Return:

TypeDescription
StringThe
error message
day of week value.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetDayOfWeekUTC
linenumberstrue
var simple_date_timeconst holidayDateTime = new SimpleDateTime('2019-zz01-0107 08:00:00');
ss.info(simple_date_time.getErrorMsgholidayDateTime.getDayOfWeekUTC()); )// Mon
getLocalDate

getDaysInMonthUTC()


This method returns the date stored number of days in the month saved by the SimpleDateTime object, showed in the 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
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(simple_date_time.getLocalDatestartDateTime.getDaysInMonthUTC() ); // 2019-01-01
getLocalTime
31

isValid()


This method returns a SimpleDateTime object that shows the time in the user's time zone.allows to determine if a specified value is a valid date and time. 


Return:

TypeDescription
SimpleDateTime
BooleanThe
time in the user's time zone
method returns TRUE if the value is a valid date and time; otherwise, it returns .


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimeisValid
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
var time = first_simple_date_time.getLocalTime();
ss.info( "My local time is " + time.getByFormat('h:m:s') ) ; // My local time is 02:01:00
getMonthLocalTime
startDateTime.setValue("2011-aa-01 00:00:00");
ss.info(startDateTime.isValid());  // false

getErrorMsg()


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


Return:

TypeDescription
StringThe
value of the month
error message.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTimegetErrorMsg
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-01zz-01 08:00:00');
ss.info(simple_date_time.getMonthLocalTimestartDateTime.getErrorMsg() );  // January
getMonthUTC
 DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


This method returns the month saved date stored by the SimpleDateTime object, showed in the system 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
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info( first_simple_date_time.getMonthUTCstartDateTime.getLocalDate() ); // January
getNumericValue
2019-01-01

getLocalTime()


This method gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00.returns a SimpleDateTime object that shows the time in the user's time zone.


Return:

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


Example:

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

getMonthLocalTime()


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


Return:

TypeDescription
SimpleDateTime
StringThe
Unix duration stamp
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetTimegetMonthLocalTime
linenumberstrue
var first_simple_date_time const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
var time = first_simple_date_time.getTime();
ss.info( timestartDateTime.getByFormat('h:m:s') getMonthLocalTime()); // 11:01:00
getValue
January

getMonthUTC()


This method gets the date and time value in the internal formatreturns the month saved by SimpleDateTime object, showed 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
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info( first_simple_date_time.getValuestartDateTime.getMonthUTC() ); //2019-01-01 08:00:00
getWeekOfYearLocalTime
 December

getNumericValue()


This method returns the number of the week saved 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
IntegerThe
number of the current week
timestamp value.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTimegetNumericValue
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info( first_simple_date_time.getWeekOfYearLocalTimestartDateTime.getNumericValue() ); // 11546329600
getWeekOfYearUTC

getTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTCgetTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getTime();
ss.info( first_simple_date_time.getWeekOfYearUTC() getByFormat('h:m:s')); // 1
getYearLocalTime
11:01:00

getWeekOfYearLocalTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetYearLocalTimegetWeekOfYearLocalTime
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(holidayDateTimestartDateTime.getYearLocalTimegetWeekOfYearLocalTime()); // 20201
getYearUTC

getWeekOfYearUTC()


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


Return:

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


Example:

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

getYearLocalTime()


This method allows to determine if a specified value is a valid date and time. returns the year saved by the SimpleDateTime object, showed in the user's time zone.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titleisValidgetYearLocalTime
linenumberstrue
var simple_date_timeconst holidayDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
simple_date_time.setDisplayValue("2011-aa-01 00:00:00");
ss.info(simple_date_time.isValid() ) ; ss.info(holidayDateTime.getYearLocalTime()); // false2020
setValue

getYearUTC(

dateTime

)


This method sets the date and time of the SimpleDateTime object.

Parameter(s):

NameTypeMandatoryDefault ValuedateTimeA 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

returns the year saved by the SimpleDateTime object, showed in the system time zone.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlesetValuegetYearUTC
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00");
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(startDateTimeholidayDateTime.getValuegetYearUTC());  // 2020-01-01 12:00:002019

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