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

addDays(days)


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 values.


Parameter(s):

NameTypeMandatoryDefault Value
daysintegerYN


Return:

TypeDescription
VoidThis 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.getValue()); // 2019-01-04 08:12:10

addMonths(months)


This method adds a specified number of months 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):

NameTypeMandatoryDefault Value
monthsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

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

addSeconds(seconds)


This method adds a specified number of seconds to the current SimpleDateTime object.


Parameter(s):

NameTypeMandatoryDefault Value
secondsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddSeconds
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addSeconds(3600);
ss.info(registrationDateTime.getValue()); // 2019-01-01 09: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(years)


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 values.


Parameter(s):

NameTypeMandatoryDefault Value
yearsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddYears
linenumberstrue
const contractStartDateTime = new SimpleDateTime('2019-01-01 00:00:00');
contractStartDateTime.addYears(1);
ss.info(contractStartDateTime.getValue()); // 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 method returns TRUE, if the current date is after the specified; otherwise returns FALSE.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titleafter
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartLaterThanEnd = startDateTime.after(endDateTime);
ss.info(isStartLaterThanEnd); // 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 false.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlebefore
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(isStartBeforeEnd); // true

compareTo(dateTime)


This method compares two date and time objects to determine whether they are equivalent or not.


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
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(thirdDateTime.compareTo(secondDateTime )); // 0
ss.info(firstDateTime.compareTo(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 Value
dateTimeSimpleDateTime object.YN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titleequals
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(firstDateTime.equals(secondDateTime)); // false
ss.info(thirdDateTime.equals(secondDateTime)); // 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
titlegetDate
linenumberstrue
const startDateTime = 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 holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTime()); // 7

getDayOfMonthUTC()


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


Return:

TypeDescription
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthUTC()); // 7

getDayOfWeekLocalTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTime
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekLocalTime()); // Mon

getDayOfWeekUTC()


This method returns the day of the week saved by the SimpleDateTime object, 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
titlegetDayOfWeekUTC
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekUTC()); // Mon

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

getDaysInMonthUTC()


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


Return:

TypeDescription
IntegerThe number of days value.


Example:

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

getDisplayValue()


This method gets the date and time value in the current user's display format and timezone.


Return:

TypeDescription
StringThe date and time value.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDisplayValue()) ; // 2019-01-01 11:00:00

getErrorMsg()


This method gets the error message if the SimpleDateTime object was incorrect.


Return:

TypeDescription
StringThe error message.


Example:

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

getLocalDate()


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


Return:

TypeDescription
StringThe date in the user's time zone.


Example:

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

getLocalTime()


This method returns a SimpleDateTime object that shows the time in the user's time zone.


Return:

TypeDescription
SimpleDateTimeThe time in the user's time zone.


Example:

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

getMonthLocalTime()


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


Return:

TypeDescription
StringThe value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTime.getMonthLocalTime()); // January

getMonthUTC()


This method returns the month saved by SimpleDateTime object, showed in the system time zone.


Return:

TypeDescription
StringThe value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTime.getMonthUTC()); // December

getNumericValue()


This method gets the timestamp which stores the amount of seconds since January 1, 1970, 00:00:00.


Return:

TypeDescription
IntegerThe timestamp value.


Example:

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

getTime()


This method returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime object.


Return:

TypeDescription
SimpleDateTimeThe Unix duration stamp.


Example:

Code Block
languagejs
themeEclipse
titlegetTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getTime();
ss.info(time.getByFormat('h:m:s')); // 11:01:00

getValue()


This method gets the date and time value in the internal format.


Return:

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


Example:

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

getWeekOfYearLocalTime()


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


Return:

TypeDescription
IntegerThe number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTime.getWeekOfYearLocalTime()); // 1

getWeekOfYearUTC()


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


Return:

TypeDescription
IntegerThe number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTime.getWeekOfYearUTC()); // 1

getYearLocalTime()


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


Return:

TypeDescription
IntegerFour-digit year value.


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 value.


Example:

Code Block
languagejs
themeEclipse
titlegetYearUTC
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(holidayDateTime.getYearUTC()); // 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());  // false

setValue(dateTime)


This method 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


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());  // 2020-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