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');

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

Example:

Code Block
languagejs
themeEclipse
titleaddDays
linenumberstrue
const registrationDateTimeyesterdayDatetime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addDays(3yesterday');
ss.info(registrationDateTimeyesterdayDatetime.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.

Info: 2022-02-28 00:00:00  

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


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

addWeeks(weeks)


This method is used to change 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
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());
//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 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
monthsyearsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

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

after(

seconds

dateTime)


This method adds a specified number of seconds to the current SimpleDateTime objectallows 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
secondsdateTimeIntegerSimpleDateTime 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
titleaddSecondsafter
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const registrationDateTimeendDateTime = new SimpleDateTime('2019-01-01 08:1200:1000');
registrationDateTime.addSeconds(3600const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(registrationDateTime.getValue(isStartAfterThanEnd)); 
// 2019-01-01 09:12:10
addWeeks(weeks
Info: false

before(dateTime)


This method adds a specified number of weeks to the current SimpleDateTime object. The negative value of the parameter will subtract the weeks.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 falseThe 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
weeksdateTimeIntegerSimpleDateTime objectYN


Return:

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


Example:

Code Block
languagejs
themeEclipse
titleaddWeeksbefore
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const registrationDateTimeendDateTime = new SimpleDateTime('2019-01-01 08:1200:1000');
registrationDateTime.addWeeks(1
const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(registrationDateTime.getValue(isStartBeforeEnd)); 
// 2019-01-08 08:12:10
addYears(years
Info: true

compareTo(dateTime)


This method adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.The method determines local date and time equivalent to the value saved by the SimpleDateTime object, then adds or subtracts the years using local date and time valuescompares 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
yearsdateTimeIntegerSimpleDateTime objectYN


Return:

TypeDescription
VoidThis method does not return a value
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
titleaddYearscompareTo
linenumberstrue
const contractStartDateTimebegin = new SimpleDateTime('2019-04-01 08:15:00');
const end = new SimpleDateTime('2019-05-01 0001:00:00');
contractStartDateTime.addYears(1);
ss.info(begin.compareTo(end));   // -1
ss.info(end.compareTo(begin));   // 1
ss.info(contractStartDateTimebegin.getValuecompareTo(begin)); // 2020-01-01 00:00:00
after
0

equals(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 FALSEcompares a datetime with an existing value to determine whether they are equal or not.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return:

TypeDescription
BooleanThe This method returns TRUE if the current date is later than the date specified by the parameterdate are equal; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleafterequals
linenumberstrue
const startDateTimefirstDateTime = new SimpleDateTime('2018-01-01 0708:5800:3500');
const endDateTimesecondDateTime = new SimpleDateTime('20192018-01-01 08:0015:00');
const isStartLaterThanEndthirdDateTime = startDateTime.after(endDateTime new SimpleDateTime('2018-01-01 08:00:00');

ss.info(firstDateTime.equals(secondDateTime));
ss.info(isStartLaterThanEndthirdDateTime.equals(firstDateTime));
//Info: false
//Info: 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
true

getDate()


This method returns the date saved by the SimpleDateTime object in the system time zone.

dateTimeSimpleDateTime objectYN


Return:

TypeDescription
Boolean
StringThe
method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE
date in the default timezone.


Example:

Code Block
languagejs
themeEclipse
titlebefore
linenumberstrue
getDate
linenumberstrue
const startDateTimeconst startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartBeforeEnd = ss.info(startDateTime.beforegetDate(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
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.

dateTimeSimpleDateTime objectYN


Return:

TypeDescription
0Dates are equal1Object's date is after the date specified in the parameter.-1Object's date is before the date specified in the parameter
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titlecompareTogetDaysofMonthsLocalTime
linenumberstrue
const firstDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTime());
const secondDateTime = new SimpleDateTime(//Info: 7

getDayOfMonthUTC()


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


Return:

TypeDescription
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTime'2018-01-01 08:00:00');
const thirdDateTime = new SimpleDateTime('20182019-01-01 08:00:00');


ss.info(thirdDateTime.compareTo(secondDateTime )); // 0
ss.info(firstDateTime.compareTo(secondDateTime)); // 107 08:00:00');
ss.info(secondDateTimeholidayDateTime.compareTogetDayOfMonthUTC(firstDateTime)); 
//Info: -17
equals

getDayOfWeekLocalTime(

dateTime

)


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

Parameter(s):

NameTypeMandatoryDefault ValuedateTimeSimpleDateTime object.YN

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


Example:

Code Block
languagejs
themeEclipse
titleequalsgetDayOfWeekLocalTime
linenumberstrue
const firstDateTimeholidayDateTime = 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)); // false07 08:00:00');
ss.info(thirdDateTimeholidayDateTime.equalsgetDayOfWeekLocalTime(secondDateTime)); // trueMon
getDate

getDayOfWeekUTC()


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


Return:

TypeDescription
StringThe
date in the default timezone.
day of week value.
Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
languagejs
themeEclipse
titlegetDategetDayOfWeekUTC
linenumberstrue
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDategetDayOfWeekUTC()); 
// 2019-01-01Info: Mon

getDaysInMonthLocalTime()


This method returns the number of days in the month saved by the SimpleDateTime object , showed in the current 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()); 
//Info: 31
getDayOfMonthLocalTime

getDaysInMonthUTC()


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


Return:

TypeDescription
IntegerThe
day
number of
the month
days value.


Example:

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

getDisplayValue()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimegetDisplayValue
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfMonthUTCgetDisplayValue()); // current user's timezone is Europe/Moscow
// 7
getDayOfWeekLocalTime
Info: 2019-01-01 11:00:00 

getErrorMsg()


This method returns the day of the week saved by returns the error message if the SimpleDateTime object , showed in the user's time zonewas incorrect.


Return:

TypeDescription
StringThe
day of week value
error message.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTimegetErrorMsg
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-zz-01-07 08:00:00');
ss.infoerror(holidayDateTimestartDateTime.getDayOfWeekLocalTimegetErrorMsg()); 
// Mon
getDayOfWeekUTC
Error: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


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


Return:

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


Example:

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

getLocalTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetLocalTime
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info(simple_date_time.getDaysInMonthUTC() ); // 31
getDisplayValue
 "My local time is " + time.getByFormat('h:i:s'));
//Info: My local time is 02:00:00

getMonthLocalTime()


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


Return:

TypeDescription
StringThe
date and time
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValuegetMonthLocalTime
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info( simple_date_time.getDisplayValuestartDateTime.getMonthLocalTime() ) ; 
// 2019-01-01 11:00:00
getErrorMsg
Info: January

getMonthUTC()


This method gets the error message if the SimpleDateTime object was incorrectreturns the month saved by SimpleDateTime object in the system time zone.


Return:

TypeDescription
StringThe
error message
value of the month.


Example:

Code Block
languagejs
themeEclipse
titlegetErrorMsggetMonthUTC
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-zz12-0131 0823:0045:00');
ss.info(simple_date_time.getErrorMsgstartDateTime.getMonthUTC() )
getLocalDate
;
//Info: December

getNumericValue()


This method returns the date stored by the SimpleDateTime object, showed in the user's time zonethe Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDategetNumericValue
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(simple_date_time.getLocalDatestartDateTime.getNumericValue() ) ;
// 2019-01-01
getLocalTime
Info: 1546329600

getTime()


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


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTimegetTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
varconst time = first_simple_date_time.getLocalTimestartDateTime.getTime();
ss.info( "My local time is " + time.getByFormat('h:mi:s') ) ; 
// My local time is 02Info: 11:01:00
getMonthLocalTime

getValue()


This method returns the month saved by SimpleDateTime object, showed in the current user's time zonedate and time value in the internal format.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTimegetValue
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(simple_date_time.getMonthLocalTimestartDateTime.getValue() ); // January
getMonthUTC
2019-01-01 08:00:00

getWeekOfYearLocalTime()


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


Return:

TypeDescription
String
IntegerThe
value
number of the
month
current week.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthUTCgetWeekOfYearLocalTime
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info( first_simple_date_time.getMonthUTCstartDateTime.getWeekOfYearLocalTime() ); 
//Info: January1
getNumericValue

getWeekOfYearUTC()


This method gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00returns the number of the week saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
IntegerThe
timestamp value
number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetNumericValuegetWeekOfYearUTC
linenumberstrue
var simple_date_timeconst startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(simple_date_time.getNumericValuestartDateTime.getWeekOfYearUTC() ) ; 
//Info: 15463188001
getTime

getYearLocalTime()


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


Return:

TypeDescription
SimpleDateTimeThe Unix duration stamp
IntegerFour-digit year value.


Example:

Code Block
languagejs
themeEclipse
titlegetTimegetYearLocalTime
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
var time = first_simple_date_time.getTime();
ss.info( timeholidayDateTime.getByFormat('h:m:s') getYearLocalTime()); 
// 11:01:00
getValue
Info: 2020

getYearUTC()


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


Return:

TypeDescription
null | stringThe date and time value in the internal format
IntegerFour-digit year value.


Example:

Code Block
languagejs
themeEclipse
titlegetValuegetYearUTC
linenumberstrue
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info( first_simple_date_time.getValueholidayDateTime.getYearUTC() ); 
//2019-01-01 08:00:00
getWeekOfYearLocalTime
Info: 2019

isValid()


This method returns the number of the week 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
Integer
BooleanThe
number of the current week
method returns TRUE if the value is a valid date and time; otherwise, it returns .


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTimeisValid
linenumberstrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue('2011-aa-01 00:00:00');
ss.info( first_simple_date_time.getWeekOfYearLocalTimestartDateTime.isValid() ); // 1

getWeekOfYearUTC()

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

Return:

TypeDescriptionIntegerThe number of the current week.

Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTC
linenumberstrue
var first_simple_date_time = new SimpleDateTime('2019-01-01 08:00:00');
ss.info( first_simple_date_time.getWeekOfYearUTC() ); // 1

getYearLocalTime()

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

//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
IntegerFour-digit year
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlegetYearLocalTimesetValue
linenumberstrue
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45 new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(holidayDateTimestartDateTime.getYearLocalTimegetValue()); 
//Info: 2020
getYearUTC(
-01-01 12:00:00

subtract(first, second)


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

Return:

TypeDescriptionIntegerFour-digit year value.

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

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


Example:

Code Block
languagejs
themeEclipse
titleisValidsubtract #1
linenumberstrue
var simple_date_timeconst startDatetime = new SimpleDateTime('2019-0111-01 08:00:00');
simple_date_time.setDisplayValue("2011-aa-01 00 20:00:00"');
ss.info(simple_date_time.isValid() ) ;  // false

setValue(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
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

Return:

TypeDescriptionVoidThis method does not return a value.Example

:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
const startDateTimestartDatetime = new SimpleDateTime("'2019-0111-0108 0820:00:00"');
startDateTime.setValueconst endDatetime = new SimpleDateTime('20202019-0111-0108 1220:0006:0028');
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 Valuefirst

SimpleDateTime Object

YNfirst

SimpleTime Object

YNfirst

Number (milliseconds)

YNsecondSimpleDateTime ObjectNNULLsecondSimpleTime ObjectNNULLsecondNumber (milliseconds)NNULL
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 startDateTimedatetime = new SimpleDateTime("2019-01-01 08:00:00");
const periodTime = new SimpleTime();
periodTime.setValue("00:00:20");
startDateTime.subtract(periodTime);
const afterSutractDateTime = startDateTime.getTime(('2020-08-28 09:00:00');
datetime.addSeconds(-3600);
ss.info(afterSutractDateTimedatetime.getByFormat('h:m:s'getValue()); 
// 01:12:40Info: 2020-08-28 08:00:00


Table of Contents
absoluteUrltrueclassfixedPosition