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):
Name | Type | Mandatory | Default Value |
---|
dateTime | String | N | '' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | SimpleDateTime |
---|
linenumbers | true |
---|
|
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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | SimpleDateTime |
---|
linenumbers | true |
---|
|
const yesterdayDatetime = 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.
yesterday');
ss.info(yesterdayDatetime.getValue());
// 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):
Name | Type | Mandatory | Default Value |
---|
days | integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addDays |
---|
linenumbers | true |
---|
|
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):
Name | Type | Mandatory | Default Value |
---|
months | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addMonths |
---|
linenumbers | true |
---|
|
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 days using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
daysseconds | integerInteger | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addDaysaddSeconds |
---|
linenumbers | true |
---|
|
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addDaysaddSeconds(33600);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-0401 0809:12:10 |
addMonthsaddWeeks(
monthsweeks)
This method adds a specified is used to change the number of months to weeks in the current SimpleDateTime object according to the local date and time. The negative positive 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 valuesadds weeks to the object, the negative value diminishes the number of weeks.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
monthsweeks | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addMonthsaddWeeks |
---|
linenumbers | true |
---|
|
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addMonthsaddWeeks(-1);
ss.info(registrationDateTime.getValue());
//Info: 20182019-1201-0108 08:12:10 |
addSecondsaddYears(
secondsyears)
This method adds a specified is used to change the number of seconds to 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 years.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
secondsyears | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addSecondsaddYears |
---|
linenumbers | true |
---|
|
const registrationDateTimecontractStartDateTime = new SimpleDateTime('2019-01-01 0800:1200:1000');
registrationDateTimecontractStartDateTime.addSecondsaddYears(36001);
ss.info(registrationDateTimecontractStartDateTime.getValue());
//Info: 20192020-01-01 0900:1200:1000 |
addWeeksafter(
weeksdateTime)
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 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 weeks using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
weeksdateTime | IntegerSimpleDateTime object | Y | N |
Return:
VoidThis method does not return a valueThe method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeks |
---|
linenumbers | true |
---|
| after |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTimeconst registrationDateTime = new SimpleDateTime('2019-01-01 08:1200:1000');
registrationDateTime.addWeeks(1const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(registrationDateTime.getValue()isStartAfterThanEnd);
// 2019-01-08 08:12:10 |
addYears(yearsbefore(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 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 years using local date and time values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
yearsdateTime | IntegerSimpleDateTime object | Y | N |
Return:
Void | This method does not return a valueBoolean | The method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addYearsbefore |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const contractStartDateTimeendDateTime = new SimpleDateTime('2019-01-01 0008:00:00');
contractStartDateTime.addYears(1const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(contractStartDateTime.getValue()); // 2020-01-01 00:00:00 |
afterisStartBeforeEnd);
//Info: true |
compareTo(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 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):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
Type | Description | | Description |
---|
0 | Dates are equal. |
1 | Object's date is after the date specified in the parameter. |
-1 | Object's date is before the date specified in the parameter | Boolean | The method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | aftercompareTo |
---|
linenumbers | true |
---|
|
const startDateTimebegin = new SimpleDateTime('20182019-0104-01 0708:5815:3500');
const endDateTimeend = new SimpleDateTime('2019-0105-01 08:00:00');
const isStartLaterThanEnd = startDateTime.after(endDateTime);01:00:00');
ss.info(begin.compareTo(end)); // -1
ss.info(end.compareTo(begin)); // 1
ss.info(isStartLaterThanEndbegin.compareTo(begin)); // false0 |
beforeequals(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 falsecompares a datetime with an existing value to determine whether they are equal or not.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object. | Y | N |
Return:
Type | Description |
---|
Boolean | The This method returns TRUE if the current date is earlier than the date specified by the parameterdate are equal; otherwise, it returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | beforeequals |
---|
linenumbers | true | | true |
---|
|
const firstDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const secondDateTimeconst startDateTime = new SimpleDateTime('2018-01-01 0708:5815:3500');
const endDateTimethirdDateTime = new SimpleDateTime('20192018-01-01 08:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTime
ss.info(firstDateTime.equals(secondDateTime));
ss.info(isStartBeforeEnd(thirdDateTime.equals(firstDateTime));
//Info: false
// true |
compareTo(dateTime)
This method compares two date and time objects to determine whether they are equivalent or not.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
0 | Dates are equal |
1 | Object's date is after the date specified in the parameter. |
-1 | Object's date is before the date specified in the parameter. |
getDate()
This method returns the date saved by the SimpleDateTime object in the system time zone.
Return:
Type | Description |
---|
String | The date in the default timezone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDate |
---|
linenumbers | true |
---|
|
const startDateTime |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | compareTo |
---|
linenumbers | true |
---|
|
const firstDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const secondDateTime = new SimpleDateTime('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)); // 1
ss.info(secondDateTimestartDateTime.compareTogetDate(firstDateTime));
//Info: 2019-101-01 |
equalsgetDayOfMonthLocalTime(
dateTime)
This method compares a datetime with an existing value if they are equal.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object. | Y | N |
returns the day of the month saved by the SimpleDateTime object in the current user's time zone.
Return:
Boolean | This method returns TRUE if the date are equal; otherwise, it returns FALSEInteger | The day of the month value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | equals |
---|
linenumbers | true |
---|
getDaysofMonthsLocalTime | linenumbers | true |
---|
|
const holidayDateTimeconst firstDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const secondDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const thirdDateTime = new SimpleDateTime('20182019-01-0107 08:00:00');
ss.info(firstDateTimeholidayDateTime.equalsgetDayOfMonthLocalTime(secondDateTime)); // false
ss.info(thirdDateTime.equals(secondDateTime)); //Info: true7 |
getDategetDayOfMonthUTC()
This method returns the date stored day of the month saved by the SimpleDateTime object , showed in the system UTC time zone.
Return:
String date in the default timezone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDategetDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDategetDayOfMonthUTC());
// 2019-01-01 |
getDayOfMonthLocalTimegetDayOfWeekLocalTime()
This method returns the day of the month week saved by the SimpleDateTime object , showed in the user's time zone.
Return:
in the current user's time zone.
Return:
Type | Description |
---|
String | The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
Type | Description |
---|
Integer | The day of the month value.
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTimegetDayOfWeekLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTimegetDayOfWeekLocalTime()); // 7Mon |
getDayOfMonthUTCgetDayOfWeekUTC()
This method returns the day of the month week saved by the SimpleDateTime object , showed in the UTC system time zone.
Return:
Integer | String | The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
The day of the month value.
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTimegetDayOfWeekUTC |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthUTCgetDayOfWeekUTC());
//Info: 7Mon |
getDayOfWeekLocalTimegetDaysInMonthLocalTime()
This method returns the day number of days in the week month saved by the SimpleDateTime object , showed in the current user's time zone.
Return:
String day week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekLocalTimegetDaysInMonthLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekLocalTimegetDaysInMonthLocalTime());
//Info: Mon31 |
getDayOfWeekUTCgetDaysInMonthUTC()
This method returns the day number of days in the week month saved by the SimpleDateTime object , showed in the system time zone.
Return:
String day week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekUTCgetDaysInMonthUTC |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfWeekUTCgetDaysInMonthUTC());
//Info: Mon31 |
getDaysInMonthLocalTimegetDisplayValue()
This method returns the number of days in the month saved by the SimpleDateTime object, showed in the date and time value in the current user's time zonedisplay format and timezone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthLocalTimegetDisplayValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDaysInMonthLocalTimegetDisplayValue()); // 31 |
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:
Integer number of days value
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthUTCgetErrorMsg |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01zz-01 08:00:00');
ss.infoerror(startDateTime.getDaysInMonthUTC()); // 31 |
getDisplayValuegetErrorMsg());
//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:
Type | Description |
---|
String | The date |
and time value
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDisplayValuegetLocalDate |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDisplayValuegetLocalDate()) ;
//Info: 2019-01-01 11:00:00 |
getErrorMsggetLocalTime()
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:
String error messagetime in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getErrorMsggetLocalTime |
---|
linenumbers | true |
---|
|
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('2019-01-01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info( "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:
date in the user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalDategetMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getLocalDategetMonthLocalTime());
// 2019-01-01 |
getLocalTimegetMonthUTC()
This method returns a the month saved by SimpleDateTime object that shows the time in the user's system time zone.
Return:
SimpleDateTime time in the user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalTimegetMonthUTC |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-01 08:00:00');
const time = startDateTime.getLocalTime(31 23:45:00');
ss.info( "My local time is " + time.getByFormat('h:m:s'startDateTime.getMonthUTC());
// My local time is 02:01:00 |
getMonthLocalTime()
getNumericValue()
This method returns the Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00This method returns the month saved by SimpleDateTime object, showed in the current user's time zone.
Return:
StringInteger | The Unix timestamp value |
of the month
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthLocalTimegetNumericValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getMonthLocalTimegetNumericValue());
//Info: January1546329600 |
getMonthUTCgetTime()
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:
String value of the month
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthUTCgetTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
const time = startDateTime.getTime();
ss.info(startDateTimetime.getMonthUTC(getByFormat('h:i:s'));
// December |
getNumericValue()
getValue()
This method returns the date and time value in the internal formatThis method gets the Unix timestamp which stores the amount of seconds since January 1, 1970, 00:00:00.
Return:
Integer Unix timestamp valuedate and time value in the internal format. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getNumericValuegetValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getNumericValuegetValue()); // 1546329600 |
getTimegetWeekOfYearLocalTime()
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:
SimpleDateTime Unix duration stampnumber of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getTimegetWeekOfYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
const time = startDateTime.getTime();
ss.info(timestartDateTime.getByFormat('h:m:s'getWeekOfYearLocalTime());
// 11:01:00 |
getValuegetWeekOfYearUTC()
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:
null | string date and time value in the internal formatnumber of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getValuegetWeekOfYearUTC |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getValuegetWeekOfYearUTC());
// 2019-01-01 08:00:00 |
getWeekOfYearLocalTimegetYearLocalTime()
This method returns the number of the week year saved by the SimpleDateTime object , showed in the current user's time - zone.
Return:
The number of the current week
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearLocalTimegetYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTimeholidayDateTime.getWeekOfYearLocalTimegetYearLocalTime());
//Info: 12020 |
getWeekOfYearUTCgetYearUTC()
This method returns the number of the week year saved by the SimpleDateTime object , showed in the system time - zone.
Return:
The number of the current week
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearUTCgetYearUTC |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(startDateTimeholidayDateTime.getWeekOfYearUTCgetYearUTC());
//Info: 12019 |
getYearLocalTimeisValid()
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:
Integer | Four-digit year valueBoolean | The method returns TRUE if the value is a valid date and time; otherwise, it returns . |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearLocalTimeisValid |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45-01-01 08:00:00');
startDateTime.setValue('2011-aa-01 00:00:00');
ss.info(holidayDateTimestartDateTime.getYearLocalTimeisValid());
//Info: 2020false |
getYearUTCsetValue(dateTime)
This method
returns the year saved by is intended to define the date and time value within the SimpleDateTime object
, showed in the system time zone.
Return:
Parameter(s):
DescriptionInteger | Four-digit year value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearUTC |
---|
linenumbers | true |
---|
|
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. dateTime | A string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss. | Y | N |
dateTime | A SimpleDateTime object. | Y | N |
dateTime | A JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00. | Y | N |
Return:
BooleanThe method returns TRUE if the value is a valid date and time; otherwise, it returns This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isValidsetValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue("2011'2020-aa01-01 0012:00:00"');
ss.info(startDateTime.isValidgetValue()); // false |
setValue(dateTime
//Info: 2020-01-01 12:00:00 |
subtract(first, second)
This method sets returns the date and time of the SimpleDateTime object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | A string in the local time zone and the internal format of yyyy-MM-dd HH:mm:ss. | Y | N |
dateTime | A SimpleDateTime object, | Y | N |
dateTime | A JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00. | Y | N |
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):
Name | Type | Mandatory | Default Value |
---|
first | SimpleDateTime Object | Y | N |
second | SimpleDateTime Object | N | NULL |
Return:
Type |
---|
SimpleDuration object |
Return:
Type | Description |
---|
Void | This method does not return a value.
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setValuesubtract #1 |
---|
linenumbers | true |
---|
|
const startDateTimestartDatetime = new SimpleDateTime('2019-0111-01 08:00:00');
startDateTime.setValue('2020-01-01 12 20: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):
Name | Type | Mandatory | Default Value |
---|
first | SimpleDateTime Object | Y | N |
first | SimpleTime Object | Y | N |
first | Number (milliseconds) | Y | N |
second | SimpleDateTime Object | N | NULL |
second | SimpleTime Object | N | NULL |
second | Number (milliseconds) | N | NULL |
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:
Type |
---|
SimpleDuration object |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse | title | subtract |
---|
linenumbers | true |
---|
|
const startDatetime = new SimpleDateTime('2019-11-08 20:00:00');
const endDatetimeconst plannedDateTime = new SimpleDateTime(current.actual_end_datetime); // '2019-11-08 20:00:00'
const actualDateTime('2019-11-08 20:06:28');
const diffSeconds = endDatetime.getNumericValue() - startDatetime.getNumericValue();
ss.info(diffSeconds);
// Info: 388 |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | true |
---|
|
const datetime = new SimpleDateTime(current.planned_end_datetime); // '2019-11-08 20:06:28'
if (actualDateTime.after(plannedDateTime)) {
const duraction = actualDateTime.subtract(plannedDateTime, actualDateTime); // 388
if '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:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | true |
---|
|
const datetime = new SimpleDateTime('2020-08-28 09:00:00');
datetime.addSeconds(-3600);
ss.info(datetime.getValue());
//Info: 2020-08-28 08:00:00(duraction.getDurationSeconds() > 300) { // more than 5 minutes
ss.eventQueue('notify.change_manager', current, current.assigned_user.getValue('manager'));
}
} |