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 exampleThe class is used to conduct operations on SimpleDateTime objects, for example, instantiating objects.

You can also use this class to perform calculate, change formats of the date-time operations, such as calculations, formatting or converting between 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. Specify the date and time value 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-01'); // 2019-05-01yesterday');
ss.info(yesterdayDatetime.getValue());
// Info: 2022-02-28 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 ValuedaysintegerYN

Return:

TypeDescriptionVoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titleaddDays
linenumberstrue
const 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: 2022-02-28 06:30:00

const fistDayOfNextMonthStart = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addDays(3first day of next month 00:00');
ss.info(registrationDateTimefistDayOfNextMonthStart.getValue()); 
// 2019Info: 2022-04-01-04 0800: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 ValuemonthsIntegerYN

Return:

TypeDescriptionVoidThis 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(-100:00

const rangeStartDatetime = new SimpleDateTime(`first day of ${monthName}`);
ss.info(rangeStartDatetime .getValue());
// Info: 2022-02-01 00: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(registrationDateTime.getValue(monthName)); 
// 2018-12-01 08:12:10
addSeconds(seconds
Info: February


addDays(days)


This method adds a specified is used to change the number of seconds to 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 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 adds a specified is used to change the number of weeks to months in the current SimpleDateTime object according to the local date and time. The negative positive 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 valuesadds months to the object, the negative value diminishes the number of months.


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 adds a specified is used to change the number of years to seconds in the current SimpleDateTime object according to the local date and time. The negative positive 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 valuesadds seconds to the object, the negative value diminishes the number of seconds.


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('20182019-01-01 0708:5812:3510');
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.

registrationDateTime.addWeeks(1);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-08 08:12:10

addYears(years)


This method is used to change 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 yearsThe method returns TRUE, if the current date is before the specified; otherwise returns false.


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.

Example:

This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlebeforeaddYears
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTimecontractStartDateTime = new SimpleDateTime('2019-01-01 0800:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTimecontractStartDateTime.addYears(1);
ss.info(contractStartDateTime.getValue(isStartBeforeEnd)); 
// true
compareTo
Info: 2020-01-01 00:00:00

after(dateTime)


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

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('20182019-01-01 08:00:00');
const thirdDateTimeisStartAfterThanEnd = new SimpleDateTime('2018-01-01 08:00:00');

startDateTime.after(endDateTime);
ss.info(thirdDateTime.compareTo(secondDateTime )isStartAfterThanEnd); // 0
ss.info(firstDateTime.compareTo(secondDateTime)); // 1
ss.info(secondDateTime.compareTo(firstDateTime)); // -1
equals
Info: false

before(dateTime)


This method compares a datetime with an existing value if they are equalallows 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 object.YN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titleequalsbefore
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');

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:

startDateTime.before(endDateTime);
ss.info(isStartBeforeEnd);
//Info: true

compareTo(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.


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
TypeDescriptionStringThe date in the default timezone
.


Example:

Code Block
languagejs
themeEclipse
titlegetDatecompareTo
linenumberstrue
const startDateTimebegin = new SimpleDateTime('2019-04-01 08:15:00');
const end = new SimpleDateTime('2019-05-01 0801:00:00');

ss.info(startDateTimebegin.getDatecompareTo(end));   // 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:

-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
TypeDescriptionIntegerThe day of the month value
.


Example:

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

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

getDate()


This method returns the day of the month date saved 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
Info: 2019-01-01

getDayOfMonthLocalTime()


This method returns the day of the week month saved by the SimpleDateTime object , showed in the 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
languagejs
themeEclipse
titlegetDaysofMonthsLocalTime
Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTime
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekLocalTimegetDayOfMonthLocalTime()); 
//Info: Mon7
getDayOfWeekUTC

getDayOfMonthUTC()


This method returns the day of the week month saved by the SimpleDateTime object , showed in the system UTC 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
languagejs
Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTCgetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekUTCgetDayOfMonthUTC()); 
//Info: Mon7
getDaysInMonthLocalTime

getDayOfWeekLocalTime()


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


Return:

TypeDescription
Integer
StringThe
number
day of
days
week value.

Example:

Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
language
Code Block
languagejs
themeEclipse
titlegetDaysInMonthLocalTimegetDayOfWeekLocalTime
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDaysInMonthLocalTimegetDayOfWeekLocalTime()); // 31Mon
getDaysInMonthUTC

getDayOfWeekUTC()


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


Return:

TypeDescription
Integer
StringThe
number
day of
days
week value.

Example:

Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

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

getDaysInMonthLocalTime()


This method gets the date and time value returns the number of days in the month saved by the SimpleDateTime object in the current user's display format and timezonetime zone.


Return:

TypeDescription
String
IntegerThe
date and time
number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetDaysInMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDisplayValuegetDaysInMonthLocalTime()) ; 
// 2019-01-01 11:00:00
getErrorMsg
Info: 31

getDaysInMonthUTC()


This method gets the error message if returns the number of days in the month saved by the SimpleDateTime object was incorrectin the system time zone.


Return:

TypeDescription
String
IntegerThe
error message
number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetDaysInMonthUTC
linenumberstrue
const startDateTime = new SimpleDateTime('2019-zz01-01 08:00:00');
ss.info(startDateTime.getErrorMsggetDaysInMonthUTC()); 
// DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given
getLocalDate
Info: 31

getDisplayValue()


This method returns the date stored by the SimpleDateTime object, showed and time value in the current user's time zonedisplay format and timezone.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDategetDisplayValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getLocalDategetDisplayValue()); // current user's timezone is Europe/Moscow
//Info: 2019-01-01
getLocalTime
 11:00:00 

getErrorMsg()


This method returns a SimpleDateTime object that shows the time in the user's time zonethe error message if the SimpleDateTime object was incorrect.


Return:

TypeDescription
SimpleDateTime
StringThe
time in the user's time zone
error message.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimegetErrorMsg
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01zz-01 08:00:00');
const time = ss.error(startDateTime.getLocalTimegetErrorMsg());
ss.info( "My local time is " + time.getByFormat('h:m:s')); // My local time is 02:01:00
getMonthLocalTime
//Error: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


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


Return:

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


Example:

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

getLocalTime()


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


Return:

TypeDescription
String
SimpleDateTimeThe
value of the month
time in the user's time zone.


Example:

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

ss.info( "My local time is " + time.getByFormat('h:i:s'));
//Info: My local time is 02:00:00

getMonthLocalTime()


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


Return:

TypeDescription
Integer
StringThe
Unix timestamp
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetNumericValuegetMonthLocalTime
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getNumericValuegetMonthLocalTime()); 
//Info: 1546329600January
getTime

getMonthUTC()


This method returns a the month saved by SimpleDateTime object that shows in the piece of time of the SimpleDateTime objectsystem time zone.


Return:

TypeDescription
SimpleDateTime
StringThe
Unix duration stamp
value of the month.


Example:

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

getNumericValue()


This method gets the date and time value in the internal formatreturns the Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.


Return:

TypeDescription
null | string
IntegerThe
date and time value in the internal format
Unix timestamp value.


Example:

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

getTime()


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


Return:

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


Example:

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

getValue()


This method returns the number of the week saved by the SimpleDateTime object, showed in the system time-zonedate and time value in the internal format.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTCgetValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getWeekOfYearUTCgetValue()); // 1
getYearLocalTime
2019-01-01 08:00:00

getWeekOfYearLocalTime()


This method returns the year saved week's number saved by the SimpleDateTime object , showed in the current 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()); 
//Info: 20201
getYearUTC

getWeekOfYearUTC()


This method returns the number of the year 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()); 
//Info: 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 in the current user's time zone.


Return:

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

Example:

IntegerFour-digit year value.


Example:

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

getYearUTC(

dateTime

)


This method sets the date and time of returns the year saved by the SimpleDateTime object in the system time zone.


Parameter(s)Return:

Name
Type
Mandatory
Description
Default 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

Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetYearUTC
linenumberstrue
const holidayDateTime 

Example:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-0112-0131 08:00:00');
startDateTime.setValue('2020-01-01 12:0023:45:00');
ss.info(startDateTimeholidayDateTime.getValuegetYearUTC());  
// 2020-01-01 12:00:00
subtract(first, second
Info: 2019

isValid()


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 Valuefirst

SimpleDateTime Object

YNfirst

SimpleTime Object

YNfirst

Number (milliseconds)

YNsecondSimpleDateTime ObjectNNULLsecondSimpleTime ObjectNNULLsecondNumber (milliseconds)NNULL

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 startDatetime = new SimpleDateTime('2019-11-08 20:00:00');
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffDuration = 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


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

Same example without using of the subtract

Return:

TypeSimpleDuration objectExample

:

Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const startDateTime = new SimpleDateTime("2019-01-01 08:00:00");
const periodTimedatetime = new SimpleTime();
periodTime.setValue("SimpleDateTime('2020-08-28 09:00:00:20"');
startDateTimedatetime.subtract(periodTime);
const afterSutractDateTime = startDateTime.getTime(addSeconds(-3600);
ss.info(afterSutractDateTimedatetime.getByFormat('h:m:s'getValue()); 
// 01:12:40Info: 2020-08-28 08:00:00


Table of Contents
absoluteUrltrue