The class is used to conduct operations on SimpleDateTime objects, for example, instantiating objects.
You can also use this class to calculate, change formats of the 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 (expects UTC value). 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'yesterday');
ss.info(yesterdayDatetime.getValue());
// Info: 2022-02-28 00:00:00
const tomorrowDatetime = new SimpleDateTime('tomorrow');
ss.info(laborDayStarttomorrowDatetime.getValue());
// Info: 20192022-0503-0102 00:00:00 |
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
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:10first day of next month 00:00');
registrationDateTime.addDays(3ss.info(fistDayOfNextMonthStart.getValue());
// Info: 2022-04-01 00:00:00
const rangeStartDatetime = new SimpleDateTime(`first day of ${monthName}`);
ss.info(registrationDateTimerangeStartDatetime .getValue());
// Info: 20192022-02-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(-100: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);
// Info: 2018-12-01 08:12:10 |
addSeconds(seconds
addDays(days)
This method is used to change the number of seconds days in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds seconds days to the object, the negative value diminishes the number of secondsdays.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
secondsdays | Integerinteger | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addSecondsaddDays |
---|
linenumbers | true |
---|
|
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addSecondsaddDays(36003);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-0104 0908:12:10 |
addWeeksaddMonths(
weeksmonths)
This method is used to change the number of weeks months in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds weeks months to the object, the negative value diminishes the number of weeksmonths.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
weeksmonths | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeksaddMonths |
---|
linenumbers | true |
---|
|
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 |
addYearsaddSeconds(
yearsseconds)
This method is used to change the number of years seconds in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds years seconds to the object, the negative value diminishes the number of yearsseconds.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
yearsseconds | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addYearsaddSeconds |
---|
linenumbers | true |
---|
|
const contractStartDateTimeregistrationDateTime = new SimpleDateTime('2019-01-01 0008:0012:0010');
contractStartDateTimeregistrationDateTime.addYearsaddSeconds(13600);
ss.info(contractStartDateTimeregistrationDateTime.getValue());
//Info: 20202019-01-01 0009:0012:0010 |
afteraddWeeks(
dateTimeweeks)
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 FALSEmethod 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):
Name | Type | Mandatory | Default Value |
---|
dateTimeweeks | SimpleDateTime objectInteger | Y | N |
Return:
Description | Boolean | The method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSEDescription |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | afteraddWeeks |
---|
linenumbers | true |
---|
|
const startDateTimeregistrationDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:0012:0010');
const isStartLaterThanEnd = startDateTime.after(endDateTimeregistrationDateTime.addWeeks(1);
ss.info(isStartLaterThanEndregistrationDateTime.getValue());
//Info: false |
before(dateTimeaddYears(years)
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 before the specified; otherwise returns falsechange 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 years.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTimeyears | SimpleDateTime objectInteger | Y | N |
Return:
BooleanThe 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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | addYears |
---|
linenumbers | true |
---|
|
const contractStartDateTime |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | before |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 0800:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTimecontractStartDateTime.addYears(1);
ss.info(isStartBeforeEndcontractStartDateTime.getValue());
//Info: true |
compareTo(dateTime)
after(dateTime)
This method allows to compare the date specified by the ‘dateTime‘ parameter with the current date.
The method returns TRUE, if the current date is after the specified; otherwise returns FALSEThis 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):
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. |
Boolean | The method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE | -1 | Object's date is before the date specified in the parameter. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | compareToafter |
---|
linenumbers | true |
---|
|
const firstDateTimestartDateTime = new SimpleDateTime('20192018-01-01 0807:0058:0035');
const secondDateTimeendDateTime = new SimpleDateTime('2019-01-01 08:15:00');
const thirdDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(firstDateTime.compareTo(thirdDateTime));
ss.info(secondDateTime.compareTo(thirdDateTime)):00');
const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(firstDateTime.compareTo(secondDateTime)isStartAfterThanEnd);
//Info: 0
//Info: 1
//Info: -1 |
equalsbefore(dateTime)
This method compares a datetime with an existing value to determine whether they are equal or notallows 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):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object. | Y | N |
Return:
Type | Description |
---|
Boolean | This 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 |
---|
language | js |
---|
theme | Eclipse |
---|
title | equalsbefore |
---|
linenumbers | true |
---|
|
const firstDateTimestartDateTime = new SimpleDateTime('2018-01-01 0807:00:00');
const secondDateTime = new SimpleDateTime('2018-01-01 08:15:0058:35');
const thirdDateTimeendDateTime = new SimpleDateTime('20182019-01-01 08:00:00');
ss.info(firstDateTime.equals(secondDateTime))const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(thirdDateTime.equals(firstDateTimeisStartBeforeEnd));
//Info: false
//Info: true |
getDate()
This method returns the date saved by the SimpleDateTime object in the system time zone.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):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
String | 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 |
The date in the default timezone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDatecompareTo |
---|
linenumbers | true |
---|
|
const startDateTimebegin = new SimpleDateTime('2019-04-01 08:15:00');
const end = new SimpleDateTime('2019-05-01 0801:00:00');
ss.info(startDateTime.getDate(begin.compareTo(end)); // -1
ss.info(end.compareTo(begin)); // 1
ss.info(begin.compareTo(begin));
//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.
equals(dateTime)
This method compares 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:
Integer | The day of the month valueBoolean | This method returns TRUE if the date are equal; otherwise, it returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
| theme | Eclipse |
---|
title | equals |
---|
linenumbers | true |
---|
|
const firstDateTime = new SimpleDateTime('2018-01-01 08:00:00');
const secondDateTime = new SimpleDateTime('2018-01-01 08:15:00');
const thirdDateTimeconst holidayDateTime = new SimpleDateTime('20192018-01-0701 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTime(firstDateTime.equals(secondDateTime));
ss.info(thirdDateTime.equals(firstDateTime));
//Info: false
//Info: 7true |
getDayOfMonthUTCgetDate()
This method returns the day of the month date saved by the SimpleDateTime object in the UTC system time zone.
Return:
Integer day of the month valuedate in the default timezone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTimegetDate |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-01-0701 08:00:00');
ss.info(holidayDateTimestartDateTime.getDayOfMonthUTCgetDate());
//Info: 7 |
getDayOfWeekLocalTimegetDayOfMonthLocalTime()
This method returns the day of the week month saved by the SimpleDateTime object in the current user's time zone.
Return:
current user's time zone.
Return:
Type | Description |
---|
Integer | The day of the month value. |
Type | Description |
---|
String | The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekLocalTimegetDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekLocalTimegetDayOfMonthLocalTime());
//Info: Mon7 |
getDayOfWeekUTCgetDayOfMonthUTC()
This method returns the day of the week month saved by the SimpleDateTime object in the system UTC time zone.
Return:
Type | Description |
---|
Integer | The day of the month value. |
Type | Description |
---|
String | The day of week value.Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekUTCgetDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekUTCgetDayOfMonthUTC());
//Info: Mon7 |
getDaysInMonthLocalTimegetDayOfWeekLocalTime()
This method returns the number day of days in the month week saved by the SimpleDateTime object in the current user's time zone.
Return:
Integer | The number of days value. |
String | The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthLocalTimegetDayOfWeekLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDaysInMonthLocalTimegetDayOfWeekLocalTime());
//Info: 31Mon |
getDaysInMonthUTCgetDayOfWeekUTC()
This method returns the number day of days in the month week saved by the SimpleDateTime object in the system time zone.
Return:
Integer | String | The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
The number of days value.
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthUTCgetDayOfWeekUTC |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-0107 08:00:00');
ss.info(startDateTimeholidayDateTime.getDaysInMonthUTCgetDayOfWeekUTC());
//Info: 31Mon |
getDisplayValuegetDaysInMonthLocalTime()
This method returns the date and time value the number of days in the month saved by the SimpleDateTime object in the current user's display format and timezonetime zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDisplayValuegetDaysInMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDisplayValuegetDaysInMonthLocalTime()); // current user's timezone is Europe/Moscow;
//Info: 2019-01-01 11:00:00 |
getErrorMsggetDaysInMonthUTC()
This method returns the error message if number of days in the month saved by the SimpleDateTime object was incorrectin the system time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getErrorMsggetDaysInMonthUTC |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-zz01-01 08:00:00');
ss.errorinfo(startDateTime.getErrorMsggetDaysInMonthUTC());
//Error: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given |
getLocalDategetDisplayValue()
This method returns the date saved by the SimpleDateTime object and time value in the current user's time zonedisplay format and timezone.
Return:
Type | Description |
---|
String | The date |
in the user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalDategetDisplayValue |
---|
linenumbers | true |
---|
|
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 |
getLocalTimegetErrorMsg()
This method returns the time saved in a SimpleDateTime object in the current user's time zone error message if the SimpleDateTime object was incorrect.
Return:
SimpleDateTime time in the user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalTimegetErrorMsg |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getLocalTime();
ss.info( "My local time is " + time.getByFormat('h:i:s'const startDateTime = new SimpleDateTime('2019-zz-01 08:00:00');
ss.error(startDateTime.getErrorMsg());
//Info: My local time is 02:00:00 |
getMonthLocalTimeError: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given |
getLocalDate()
This method returns the month date saved by the SimpleDateTime object in the current user's time zone.
Return:
value of the monthdate in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthLocalTimegetLocalDate |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getMonthLocalTimegetLocalDate());
//Info: January |
getMonthUTCgetLocalTime()
This method returns the month time saved by in a SimpleDateTime object in the system current user's time zone .
Return:
String value of the monthtime in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthUTCgetLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 23:45:00'08:00:00');
const time = startDateTime.getLocalTime();
ss.info(startDateTime.getMonthUTC( "My local time is " + time.getByFormat('h:i:s'));
//Info: December |
getNumericValueMy local time is 02:00:00 |
getMonthLocalTime()
This method returns the Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00month saved by SimpleDateTime object in the current user's time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getNumericValuegetMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-0112-0131 0823:0045:00');
ss.info(startDateTime.getNumericValuegetMonthLocalTime());
//Info: 1546329600January |
getTimegetMonthUTC()
This method returns a the month saved by SimpleDateTime object that shows in the piece of time of the SimpleDateTime objectsystem time zone.
Return:
SimpleDateTime Unix duration stamp
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getTimegetMonthUTC |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const time = startDateTime.getTime(12-31 23:45:00');
ss.info(timestartDateTime.getByFormat('h:i:s'getMonthUTC());
//Info: 11:01:00 |
getValuegetNumericValue()
This method returns the date and time value in the internal formatUnix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.
Return:
null | string date and time value in the internal format
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getValuegetNumericValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getValuegetNumericValue());
// 2019-01-01 08:00:00 |
getWeekOfYearLocalTimegetTime()
This method returns the week's number saved by a SimpleDateTime object that shows the piece of time of the SimpleDateTime object in the current user's time zone.
Return:
Integer number of the current week
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearLocalTimegetTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
const time = startDateTime.getTime();
ss.info(startDateTimetime.getWeekOfYearLocalTime(getByFormat('h:i:s'));
//Info: 1 |
getWeekOfYearUTCgetValue()
This method returns the number of the week saved by the SimpleDateTime object in the system time zonedate and time value in the internal format.
Return:
Integer number of the current weekdate and time value in the internal format. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearUTCgetValue |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-1201-3101 2308:4500:00');
ss.info(startDateTime.getWeekOfYearUTCgetValue());
//Info: 1 |
getYearLocalTimegetWeekOfYearLocalTime()
This method returns the year saved week's number saved by the SimpleDateTime object in the current user's time zone.
Return:
Four-digit year valueThe number of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearLocalTimegetWeekOfYearLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(holidayDateTimestartDateTime.getYearLocalTimegetWeekOfYearLocalTime());
//Info: 20201 |
getYearUTCgetWeekOfYearUTC()
This method returns the number of the year week saved by the SimpleDateTime object in the system time zone.
Return:
Four-digit year valueThe number of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearUTCgetWeekOfYearUTC |
---|
linenumbers | true |
---|
|
const holidayDateTimestartDateTime = new SimpleDateTime('2019-12-31 23:45:00');
ss.info(holidayDateTimestartDateTime.getYearUTCgetWeekOfYearUTC());
//Info: 20191 |
isValidgetYearLocalTime()
This method allows to determine if a specified value is a valid date and timereturns the year saved by the SimpleDateTime object in the current user's time zone.
Return:
Boolean | The method returns TRUE if the value is a valid date and time; otherwise, it returns Integer | Four-digit year value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isValidgetYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimeholidayDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue("2011-aa-01 00:00:00"('2019-12-31 23:45:00');
ss.info(startDateTimeholidayDateTime.isValidgetYearLocalTime());
//Info: false2020 |
setValuegetYearUTC(
dateTime)
This method
is intended to define the date and time value within returns the year saved by the SimpleDateTime object in the system time zone.
Parameter(s)Return:
Name | MandatoryDefault Value | 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 | NInteger | 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());
//Info: 2019 |
isValid()
This method allows to determine if a specified value is a valid date and time.
Return:
VoidThis method does not return a valueThe method returns TRUE if the value is a valid date and time; otherwise, it returns . |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setValueisValid |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
startDateTime.setValue('20202011-01aa-01 1200:00:00');
ss.info(startDateTime.getValueisValid());
//Info: 2020-01-01 12:00:00 |
subtract(first, secondsetValue(dateTime)
This method
returns the amount of time between two SimpleDateTime values. Also, it can subtract the amount of time from the current is intended to define the date and time value within the SimpleDateTime object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
first | SimpleDateTime ObjectdateTime | A string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss. | Y | N |
first | SimpleTime ObjectdateTime | A SimpleDateTime object. | Y | N |
firstNumber (seconds) | Y | N | second | SimpleDateTime Object | N | NULL |
second | SimpleTime Object | N | NULL |
second | Number (seconds) | N | NULL |
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:
SimpleDuration object | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #1setValue |
---|
linenumbers | true |
---|
|
const plannedDateTime = new SimpleDateTime(current.actual_end_datetime); // '2019-11-08 20:00:00'
const actualDateTime = new SimpleDateTime(current.planned_end_datetime); // '2019-11-08 20:06:28'
if (actualDateTime.after(plannedDateTime)) {
const duraction = actualDateTime.subtract(plannedDateTime, actualDateTime); // 388
if (duraction.getDurationSeconds() > 300) { // more than 5 minutes
ss.eventQueue('notify.change_manager', current, current.assigned_user.getValue('manager'));
}
} |
Same example without using of the subtractstartDateTime = 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):
Name | Type | Mandatory | Default Value |
---|
first | SimpleDateTime Object | Y | N |
second | SimpleDateTime Object | N | NULL |
Return:
Type |
---|
SimpleDuration object |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #1 |
---|
linenumbers | true |
---|
|
const plannedDateTimestartDatetime = new SimpleDateTime(current.actual_end_datetime); // '2019-11-08 20:00:00');
const actualDateTime = new SimpleDateTime(current.planned_end_datetime); // endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const
if (actualDateTime.after(plannedDateTime)) {
const duraction = plannedDateTime.getNumericValue() - actualDateTime.getNumericValue(); // 388
if (duraction > 300) { // more than 5 minutes
ss.eventQueuediffDuration = new SimpleDateTime().subtract(startDatetime, endDatetime);
ss.info(diffDuration.getDurationSeconds());
// Info: 388 |
Same example without using of the subtract:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
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('notify.change_manager', current, current.assigned_user.getValue('manager'));
}
} |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | true |
---|
|
const plannedDateTimedatetime = new SimpleDateTime('2020-08-28 09:00:00');
plannedDateTimedatetime.subtract(3600);
ss.info(plannedDateTimedatetime.getDisplayValuegetValue());
//Info: 2020-08-28 1108:00:00 |
Same example without using of the subtract:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | true |
---|
|
const plannedDateTimedatetime = new SimpleDateTime('2020-08-28 09:00:00');
plannedDateTimedatetime.addSeconds(-3600);
ss.info(plannedDateTimedatetime.getDisplayValuegetValue());
//Info: 2020-08-28 1108:00:00 |