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
var simple_date_timeconst nowDateTime = new SimpleDateTime('2019-);
//
const registrationDateTime = new SimpleDateTime(record.registration_datetime);
//
const yearStartDateTime = new SimpleDateTime('2019-01-01 0800: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.

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('yesterday');
ss.info(yesterdayDatetime

Example:

Code Block
languagejs
themeEclipse
titleaddDays
linenumberstrue
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addDays(-1)
ss.info(simple_date_time.getValue()); 
// 2018-12-31 08Info: 2022-02-28 00:00:00

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.

  

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('first day of next month 00:00');
ss.info(fistDayOfNextMonthStart.getValue());
// Info: 2022-04-01 00:00: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(monthName);
// Info: February


addDays(days)


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


Parameter(s):

NameTypeMandatoryDefault 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());
//Info: 2019-01-04 08:12:10

addMonths(months)


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


Parameter(s):

NameTypeMandatoryDefault 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());
//Info: 2018-12-01 08:12:10

addSeconds(seconds)


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


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddMonthsaddSeconds
linenumberstrue
var simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addMonths(-1)registrationDateTime.addSeconds(3600);
ss.info(simple_date_timeregistrationDateTime.getValue()); 
//Info: 20182019-1201-01 0809:0012:0010
addSeconds

addWeeks(

seconds

weeks)


This method adds a specified is used to change the number of seconds to 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
secondsweeksIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddSecondsaddWeeks
linenumberstrue
var simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addSeconds(3600registrationDateTime.addWeeks(1);
ss.info(simple_date_timeregistrationDateTime.getValue()); 
//Info: 2019-01-0108 0908:0012:0010
addWeeks

addYears(

weeks

years)


This method adds a specified is used to change the number of weeks to years in the current SimpleDateTime object . The negative value of the parameter will subtract the weeks.The method determines according to the local date and time equivalent . The positive value of the parameter adds years to the value saved by the SimpleDateTime object, then adds or subtracts the weeks using local date and time valuesthe negative value diminishes the number of years.


Parameter(s):

NameTypeMandatoryDefault Value
weeksyearsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeksaddYears
linenumberstrue
var simple_date_timeconst contractStartDateTime = new SimpleDateTime("'2019-01-01 0800:00:00"');
simple_date_time.addWeeks(-contractStartDateTime.addYears(1);
ss.info(simple_date_timecontractStartDateTime.getValue()); 
//Info: 20182020-1201-2501 0800:00:00
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.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 FALSEThe 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
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
linenumberstruetrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
simple_date_time.addYears(1)const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(simple_date_time.getValue()); // 2020-01-01
after
isStartAfterThanEnd);
//Info: 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
var first_simple_date_timeconst startDateTime = new SimpleDateTime("2019'2018-01-01 0807:0058:00"35');
var second_simple_date_timeconst endDateTime = new SimpleDateTime("2018'2019-01-01 08:00:00"');
letconst resultisStartBeforeEnd = first_simple_date_time.after(second_simple_date_timestartDateTime.before(endDateTime);
ss.info(resultisStartBeforeEnd) ;
//Info: true

before(dateTime)

This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date.

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 otherThe method returns TRUE, if the current date is before the specified; otherwise returns false.


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
var first_simple_date_timeconst begin = new SimpleDateTime("'2019-0104-01 08:0015:00"');
var second_simple_date_timeconst end = new SimpleDateTime("2018'2019-0105-01 0801:00:00"');
let result = first_simple_date_time.before(second_simple_date_time);
ss.info(begin.compareTo(end));   // -1
ss.info(end.compareTo(begin));   // 1
ss.info(result)begin.compareTo(begin)); // false0
compareTo

equals(dateTime)


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


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return::

Object's date is before the date specified in the parameter
TypeDescription
BooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE
TypeDescription
0Dates are equal
1Object's date is after the date specified in the parameter.
-1.


Example:

Code Block
languagejs
themeEclipse
titlecompareToequals
linenumberstrue
var first_simple_date_timeconst firstDateTime = new SimpleDateTime("2019'2018-01-01 08:00:00"');
var second_simple_date_timeconst secondDateTime = new SimpleDateTime("'2018-01-01 08:0015:00"');
var third_simple_date_timeconst thirdDateTime = new SimpleDateTime("'2018-01-01 08:00:00"');

ss.info(firstDateTime.equals(secondDateTime));
ss.info( first_simple_date_time.compareTo(second_simple_date_time) ); // 1
ss.info( second_simple_date_time.compareTo(first_simple_date_time) ); // -1
ss.info( third_simple_date_time.compareTo(second_simple_date_time ) ); // 0

equals(dateTime)

This method compares a datetime with an existing value if they are equal.

Parameter(s):

NameTypeMandatoryDefault ValuedateTimeSimpleDateTime object.YN
thirdDateTime.equals(firstDateTime));
//Info: false
//Info: true

getDate()


This method returns the date saved by the SimpleDateTime object 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());
//Info: 2019-01-01

getDayOfMonthLocalTime()


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


Return:

TypeDescription
BooleanThis method returns TRUE if the date are equal; otherwise, it returns FALSE
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titleequals
linenumberstrue
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
var second_simple_date_time = new SimpleDateTime("2018-01-01 08:00:00");
var third_simple_date_time = new SimpleDateTime("2018'2019-01-0107 08:00:00"');

ss.info( first_simple_date_time.equals(second_simple_date_time) ); // 0
ss.info( third_simple_date_time.equals(second_simple_date_time ) ); // 1
getDate
info(holidayDateTime.getDayOfMonthLocalTime());
//Info: 7

getDayOfMonthUTC()


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


Return:

TypeDescription
String
IntegerThe
date in the default timezone
day of the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDategetDaysofMonthsLocalTime
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDateholidayDateTime.getDayOfMonthUTC() ); 
// 2019-01-01
getDaysInMonthLocalTime
Info: 7

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 value.
week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthLocalTimegetDayOfWeekLocalTime
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDaysInMonthLocalTimeholidayDateTime.getDayOfWeekLocalTime() ); // 31Mon
getDayOfMonthLocalTime

getDayOfWeekUTC()


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

Return:

TypeDescriptionIntegerThe day of the month value.

the SimpleDateTime object 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
titlegetDaysofMonthsLocalTimegetDayOfWeekUTC
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthLocalTimeholidayDateTime.getDayOfWeekUTC() ); 
//Info: 1Mon
getDayOfMonthUTC

getDaysInMonthLocalTime()


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


Return:

TypeDescription
IntegerThe
day
number of
the month
days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimegetDaysInMonthLocalTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthUTCstartDateTime.getDaysInMonthLocalTime() );
getDayOfWeekLocalTime

//Info: 31

getDaysInMonthUTC()


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


Return:

TypeDescription
String
IntegerThe
day
number of
week
days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTimegetDaysInMonthUTC
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfWeekLocalTimestartDateTime.getDaysInMonthUTC() ); 
//Info: Tue31
getDayOfWeekUTC

getDisplayValue()


This method returns the day of the week saved by the SimpleDateTime object, showed in the system time zonedate and time value in the current user's display format and timezone.


Return:

TypeDescription
StringThe
day of week
date and time value.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTCgetDisplayValue
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfWeekUTCstartDateTime.getDisplayValue() );
getDaysInMonthUTC
 // current user's timezone is Europe/Moscow
//Info: 2019-01-01 11:00:00 

getErrorMsg()


This method returns the number of days in the month saved by the SimpleDateTime object, showed in the system time zoneerror message if the SimpleDateTime object was incorrect.


Return:

TypeDescription
Integer
StringThe
number of days value
error message.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetErrorMsg
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01zz-01 08:00:00"');
ss.info( first_simple_date_time.getDaysInMonthUTC() );
getDisplayValue
error(startDateTime.getErrorMsg());
//Error: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetLocalDate
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDisplayValuestartDateTime.getLocalDate() ) ; 
//uses current user session time zone
getErrorMsg
Info: 2019-01-01

getLocalTime()


This method gets the error message if the SimpleDateTime object was incorrectreturns the time saved in a SimpleDateTime object in the current user's time zone .


Return:

TypeDescription
String
SimpleDateTimeThe
error message
time in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetLocalTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-zz01-01 08:00:00"00');
const time = startDateTime.getLocalTime();
ss.info( first_simple_date_time.getErrorMsg() ) ;  //The parsed date or time was invalid!
getLocalDate
 "My local time is " + time.getByFormat('h:i:s'));
//Info: My local time is 02:00:00

getMonthLocalTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDategetMonthLocalTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getLocalDate() )
getLocalTime
startDateTime.getMonthLocalTime());
//Info: January

getMonthUTC()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimegetMonthUTC
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
var time = first_simple_date_time.getLocalTime();
ss.info( "My local time is " + time.getByFormat('h:m:s') ) ;
getMonthLocalTime
startDateTime.getMonthUTC());
//Info: December

getNumericValue()


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


Return:

TypeDescription
String
IntegerThe Unix timestamp value
of the month
.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTimegetNumericValue
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getMonthLocalTimestartDateTime.getNumericValue() ); 
//Info: January1546329600
getMonthUTC

getTime()


This method returns the month saved by a SimpleDateTime object , showed in the system time zonethat shows the piece of time of the SimpleDateTime object.


Return:

TypeDescription
String
SimpleDateTimeThe
value of the month
Unix duration stamp.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthUTCgetTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
const time = startDateTime.getTime();
ss.info( first_simple_date_info(time.getMonthUTC() );
getNumericValue
getByFormat('h:i:s'));
//Info: 11:01:00

getValue()


This method gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00returns the date and time value in the internal format.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetNumericValuegetValue
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getNumericValuestartDateTime.getValue() ) ; // 1546318800
getTime
 2019-01-01 08:00:00

getWeekOfYearLocalTime()


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


Return:

TypeDescription
SimpleDateTime
IntegerThe
Unix duration stamp
number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetTimegetWeekOfYearLocalTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
var time = first_simple_date_time.getTime();
ss.info( timestartDateTime.getByFormat('h:m:s') );
getValue
getWeekOfYearLocalTime());
//Info: 1

getWeekOfYearUTC()


This method gets the date and time value in the internal formatreturns the number of the week saved by the SimpleDateTime object in the system time zone.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetValuegetWeekOfYearUTC
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getValuestartDateTime.getWeekOfYearUTC() ); 
//2019-01-01 08:00:00
getWeekOfYearLocalTime
Info: 1

getYearLocalTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTimegetYearLocalTime
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getWeekOfYearLocalTimeholidayDateTime.getYearLocalTime() ); 
//Info: 12020
getWeekOfYearUTC

getYearUTC()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTCgetYearUTC
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getWeekOfYearUTCholidayDateTime.getYearUTC() );
getYearLocalTime
 
//Info: 2019

isValid()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetYearLocalTimeisValid
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("2019-01'2019-01-01 08:00:00');
startDateTime.setValue('2011-aa-01 0800:00:00"');
ss.info( first_simple_date_time.getYearLocalTime()
getYearUTC(
startDateTime.isValid());
//Info: false

setValue(dateTime)


This method

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

Return:

TypeDescriptionIntegerFour-digit year value.

Example:

Code Block
languagejs
titlegetYearUTC
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
ss.info( first_simple_date_time.getYearUTC() );

isValid()

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

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
Boolean
Void
The method returns TRUE if the value is a valid date and time; otherwise, it returns FALSE
This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleisValidsetValue
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
first_simple_date_time.setDisplayValue("2011-aastartDateTime.setValue('2020-01-01 0012:00:00"');
ss.info( first_simple_date_time.isValidstartDateTime.getValue() ) ;  // false
setValue(dateTime

//Info: 2020-01-01 12:00:00

subtract(first, second)


This method sets returns the date and time of the SimpleDateTime objectamount 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
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:

TypeDescriptionVoidThis method does not return a 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

Example

:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
var first_simple_date_timeconst startDatetime = new SimpleDateTime("'2019-0111-01 08:00:00");
first_simple_date_time.setValue("2020-01-01 12:00:00");
ss.info( first_simple_date_time.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 Valuefirst

SimpleDateTime Object

YNfirst

SimpleTime Object

YNfirst

Number (milliseconds)

YNsecondSimpleDateTime ObjectNNULLsecondSimpleTime ObjectNNULLsecondNumber (milliseconds)NNULL
 20:00:00');
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffSeconds = endDatetime.getNumericValue() - startDatetime.getNumericValue(); 
ss.info(diffSeconds);
// Info: 388


Return:

TypeSimpleDuration object

Example:

Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
var simple_date_timeconst datetime = new SimpleDateTime("2019'2020-0108-0128 08:00:00");

var simple_time = new SimpleTime();
simple_time.setValue("09:00:00:20"');

simple_date_timedatetime.subtract(simple_time3600);

var second_simple_time  = simple_date_time.getTime(ss.info(datetime.getValue());
//Info: 2020-08-28 08:00:00

Same example without using of the subtract:

Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const datetime = new SimpleDateTime('2020-08-28 09:00:00');
datetime.addSeconds(-3600);
ss.info( second_simple_time.getByFormat('h:m:s') ); // 2019-01-01 07:59:40datetime.getValue());
//Info: 2020-08-28 08:00:00


Table of Contents
absoluteUrltrueclassfixedPosition