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.
addDaysLocalTimeSimpleDateTime(
daysdateTime)
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 GlideDateTime object, then adds or subtracts the days using local date and time values
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 | daysMandatory | IntegerDefault Value |
---|
Return:TypeDescription | Void | This method does not return a value.
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addDaysLocalTime | SimpleDateTime |
---|
linenumbers | true |
---|
|
const nowDateTime = new SimpleDateTime();
//
const registrationDateTime = new SimpleDateTime(record.registration_datetime);
//
const yearStartDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 0800:00:00");
simple_date_time.addDaysLocalTime(-1)'); |
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('yesterday');
ss.info(simple_date_timeyesterdayDatetime.getValue());
// 2018-12-31 |
Adds a specified number of days to the current SimpleDateTime object. The negative value of the parameter will subtract the days.
The method determines UTC date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the days using UTC date and time values.
Parameter(s):
Name | Type |
---|
days | integer |
Return:
Type | Description |
---|
Void | This method does not return a value. |
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
Example:
Code Block |
---|
language | js |
---|
title | addDaysUTC |
---|
|
var simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addDaysUTC(-1)
ss.info(simple_date_time.getValue()); // 2018-12-31 08:00:00 |
Adds a specified number of months to the current SimpleDateTime object. The negative value of the parameter will subtract the months.
The method determines local date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the months using local date and time values.
Parameter(s):
Name | Type | months | | Mandatory | Default Value |
---|
days | integer | Y | N | Integer |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addDays |
---|
linenumbers | addMonthsLocalTimetrue |
---|
|
var simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addMonthsLocalTime(1)registrationDateTime.addDays(3);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 2019-02-01 |
addMonthsUTCaddMonths(months)
Adds a specified This method is used to change the number of months to 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 UTC date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the months using UTC date and time valuesadds 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 | addMonthsUTCTimetrue |
---|
|
var simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addMonthsUTCregistrationDateTime.addMonths(-1);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 2018-12-01 08:0012:0010 |
addSeconds(seconds)
Add a specified This method is used to change the number of seconds to 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):
Name | Type | Mandatory | Default Value |
---|
seconds | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addSeconds |
---|
linenumbers | true |
---|
|
const registrationDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.registrationDateTime.addSeconds(3600);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 2019-01-01 09:0012:0010 |
addWeeksLocalTimeaddWeeks(weeks)
Adds a specified This method is used to change the number of weeks to in the current SimpleDateTime object according to the local date and time. The negative positive value of the parameter will subtract the weeks.The method determines local date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the weeks using local date and time values.adds weeks to the object, the negative value diminishes the number of weeks.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
weeksinteger | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeksLocalTime | addWeeks |
---|
linenumbers | true |
---|
|
const registrationDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addWeeksLocalTime(2)registrationDateTime.addWeeks(1);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 2019-01-15 |
addYears(years)
This method is used to change the number of years in Adds a specified number of weeks to the current SimpleDateTime object according to the local date and time. The negative positive value of the parameter will subtract the weeks.The method determines UTC date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the weeks using UTC date and time valuesadds years to the object, the negative value diminishes the number of years.
Parameter(s):
Name | Type | weeksMandatory | Default Value |
---|
years | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeksUTC | addYears |
---|
linenumbers | true |
---|
|
const contractStartDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 0800:00:00"');
simple_date_time.addWeeksUTC(-contractStartDateTime.addYears(1);
ss.info(simple_date_timecontractStartDateTime.getValue());
//Info: 20182020-1201-2501 0800:00:00 |
addYearsLocalTimeafter(
yearsdateTime)
Adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.
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 FALSEThe method determines local date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the years using local date and time values.
Parameter(s):
Name | Type | YearsMandatory | IntegerDefault Value |
---|
Return:dateTime | SimpleDateTime object | Y | N |
Return:
Type | 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 | after |
---|
linenumbers | addYearsLocalTimetrue |
---|
|
var simple_date_timeconst startDateTime = new SimpleDateTime("2019'2018-01-01 0807:0058:00");
simple_date_time.addYearsLocalTime(1)35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(simple_date_time.getValue()); // 2020-01-01 |
Adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.
isStartAfterThanEnd);
//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 falseThe method determines UTC date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the years using UTC date and time values.
Parameter(s):
Name | Type | YearsMandatory | IntegerDefault Value |
---|
Return:
Return:
Type | Description |
---|
Boolean | The method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE |
Void | This method does not return a value
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | before |
---|
linenumbers | addYearsLocalTimetrue |
---|
|
var simple_date_timeconst startDateTime = new SimpleDateTime("2019'2018-01-01 0807:0058:00");
simple_date_time.addYearsLocalTime(1)35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(simple_date_time.getValue()); // 2020-01-01 |
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:
Boolean | Returns true if the current date is later than |
---|
0 | Dates are equal. |
1 | Object's date is after the date specified |
by in the parameter. |
-1 | Object's date is before the date specified in the parameter. |
ExampleExample:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | after | compareTo |
---|
linenumbers | true |
---|
|
const beginvar first_simple_date_time = 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.after(second_simple_date_time);
ss.info(begin.compareTo(end)); // -1
ss.info(end.compareTo(begin)); // 1
ss.info(result)begin.compareTo(begin)); // true0 |
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:
Returns true 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 |
---|
title | before |
---|
theme | Eclipse |
---|
title | equals |
---|
linenumbers | true |
---|
|
const firstDateTimevar first_simple_date_time = new SimpleDateTime("2019'2018-01-01 08:00:00"');
var second_simple_date_timeconst secondDateTime = new SimpleDateTime("'2018-01-01 08:0015:00"');
letconst resultthirdDateTime = first_simple_date_time.before(second_simple_date_time) new SimpleDateTime('2018-01-01 08:00:00');
ss.info(firstDateTime.equals(secondDateTime));
ss.info(result) // false |
Compares two date and time objects to determine whether they are equivalent or not.
Parameter(s):
Name | Type |
---|
dateTime | SimpleDateTime object |
thirdDateTime.equals(firstDateTime));
//Info: false
//Info: true |
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 |
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
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | compareTo | getDate |
---|
linenumbers | true |
---|
|
const startDateTimevar 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-01-01 08:00:00");
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 |
Compares a datetime with an existing value if they are equal.
Parameter(s):
Name | Type |
---|
dateTime | SimpleDateTime object. |
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:
Type | Description |
---|
Integer | The day of the month value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthLocalTime());
//Info: 7 |
getDayOfMonthUTC()
This method returns the day of the month saved by the SimpleDateTime object in the UTC time zone.
Return:
Type | Description |
---|
Integer | The day of the month value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfMonthUTC());
//Info: 7 |
getDayOfWeekLocalTime()
This method returns the day of the week saved by the SimpleDateTime object 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' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekLocalTime()); // Mon |
getDayOfWeekUTC()
This method returns the day of the week saved by the SimpleDateTime object in the system time zone.
Return:
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 | getDayOfWeekUTC |
---|
linenumbers | true |
---|
|
const holidayDateTime = new SimpleDateTime('2019-01-07 08:00:00');
ss.info(holidayDateTime.getDayOfWeekUTC());
//Info: Mon |
getDaysInMonthLocalTime()
This method returns the number of days in the month saved by the SimpleDateTime object in the current user's time zone.
Return:
Type | Description |
---|
Integer | The number of days value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getDaysInMonthLocalTime());
//Info: 31 |
getDaysInMonthUTC()
This method returns the number of days in the month saved by the SimpleDateTime object
Return:
Type | Description |
---|
Boolean | Returns true if the date are equal; otherwise returns false. |
Example:
Code Block |
---|
|
var 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-01-01 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 |
Returns the date stored by the GlideDateTime object, showed in the system time zone.
Return:
String date in the default timezone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthUTC |
---|
linenumbers | getDatetrue |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDatestartDateTime.getDaysInMonthUTC() );
// 2019-01-01 |
getDisplayValue()
This method returns the date and time value in the current user's display format and timezoneReturns the number of days in the month saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthLocalTime | getDisplayValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDaysInMonthLocalTime() ); // 31 |
startDateTime.getDisplayValue()); // current user's timezone is Europe/Moscow
//Info: 2019-01-01 11:00:00 |
getErrorMsg()
This method returns the error message if the SimpleDateTime object was incorrectReturns the day of the month saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Integer day of the month value
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysofMonthsLocalTime | getErrorMsg |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01zz-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthLocalTimeerror(startDateTime.getErrorMsg() );
//Error: DateTimeZone::getOffset() expects parameter 1 |
getDayOfMonthUTC to be DateTimeInterface, null given |
getLocalDate()
Returns the day of the month This method returns the date saved by the SimpleDateTime object , showed in the UTC current user's time zone.
Return:
Integer day of the month valuedate in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalDate |
---|
linenumbers | truegetDaysofMonthsLocalTime |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthUTCstartDateTime.getLocalDate() ); |
getDayOfWeekLocalTimegetLocalTime()
Returns the day of the week saved by the SimpleDateTime object, showed in the This method returns the time saved in a SimpleDateTime object in the current user's time zone .
Return:
String day of week valuetime in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalTime |
---|
linenumbers | getDayOfWeekLocalTimetrue |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
const time = startDateTime.getLocalTime();
ss.info( first_simple_date_time.getDayOfWeekLocalTime() ); // Tue |
.info( "My local time is " + time.getByFormat('h:i:s'));
//Info: My local time is 02:00:00 |
getMonthLocalTime()
This method returns the month saved by SimpleDateTime object in the current user's Returns the day of the week saved by the SimpleDateTime object, showed in the system time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthLocalTime |
---|
linenumbers | getDayOfWeekUTCtrue |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getDayOfWeekUTCstartDateTime.getMonthLocalTime() ); |
getDaysInMonthUTCgetMonthUTC()
Returns the number of days in This method returns the month saved by the SimpleDateTime object , showed in the system time zone.
Return:
Integer number days value
Example:
Code Block |
---|
language | js |
---|
title | getDaysInMonthUTC |
---|
|
|
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthUTC |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getDaysInMonthUTCstartDateTime.getMonthUTC() ); |
getDisplayValuegetNumericValue()
Gets the date and time value in the current user's display format and timezoneThis method returns the Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.
Return:
Null | String |
---|
Integer | The Unix timestamp value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDisplayValue | getNumericValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDisplayValuestartDateTime.getNumericValue() ) ; //uses current user session time zone |
getTime()
This method returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime objectGets the error message if the SimpleDateTime object was incorrect.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getErrorMsg | getTime |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-zz01-01 08:00:00"00');
const time = startDateTime.getTime();
ss.info( first_simple_date_time.getErrorMsg() ) ; //The parsed date or time was invalid! |
getByFormat('h:i:s'));
//Info: 11:01:00 |
getValue()
This method returns the date and time value in the internal formatReturns the date stored by the GlideDateTime object, showed in the user's time zone.
Return:
Stringnull | string | The date and time value in the |
user's time zone
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getValue |
---|
linenumbers | getLocalDatetrue |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getLocalDate() ) |
startDateTime.getValue()); // 2019-01-01 08:00:00 |
getWeekOfYearLocalTime()
This method returns the week's number saved by the SimpleDateTime object in the current Returns a SimpleDateTime object that shows the time in the user's time zone.
Return:
SimpleDateTime time in the user's time zonenumber of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalTime | getWeekOfYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
var time = first_simple_date_time.getLocalTime( SimpleDateTime('2019-12-31 23:45:00');
ss.info( "My local time is " + time.getByFormat('h:m:s') ) ; |
startDateTime.getWeekOfYearLocalTime());
//Info: 1 |
getWeekOfYearUTC()
This method returns the number of the week saved by the SimpleDateTime object in the system Returns the month saved by SimpleDateTime object, showed in the current user's time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getMonthLocalTime | getWeekOfYearUTC |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getMonthLocalTimestartDateTime.getWeekOfYearUTC() );
//Info: January1 |
getMonthUTCgetYearLocalTime()
Returns This method returns the month year saved by the SimpleDateTime object , showed in the system in the current user's time zone.
Return:
String | The value of the monthInteger | Four-digit year value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearLocalTime |
---|
linenumbers | truegetMonthUTC |
---|
|
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getMonthUTCholidayDateTime.getYearLocalTime() ); |
getNumericValuegetYearUTC()
Gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00:00:00This method returns the year saved by the SimpleDateTime object in the system time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getNumericValue | getYearUTC |
---|
linenumbers | true |
---|
|
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getNumericValueinfo(holidayDateTime.getYearUTC() ) ;
//Info: 15463188002019 |
getTimeisValid()
Returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime objectThis method allows to determine if a specified value is a valid date and time.
Return:
SimpleDateTime | The Unix duration stampBoolean | The method returns TRUE if the value is a valid date and time; otherwise, it returns . |
Example:
Code Block |
---|
language | js |
---|
title | getTime |
---|
| js |
---|
theme | Eclipse |
---|
title | isValid |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
var time = first_simple_date_time.getTime(startDateTime.setValue('2011-aa-01 00:00:00');
ss.info( timestartDateTime.getByFormat('h:m:s') ); |
Gets isValid());
//Info: false |
setValue(dateTime)
This method is intended to define the date and time value
in within the
internal formatSimpleDateTime object.
Return:
Parameter(s):
Description | null | string | The date and time value in the internal format |
Example:
Code Block |
---|
|
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
ss.info( first_simple_date_time.getValue() ); //2019-01-01 08:00:00 |
Returns the number of the week saved by the SimpleDateTime object, showed in the user's time-zone.Mandatory | Default 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 | N |
Return:
Integer | The number of the current weekVoid | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearLocalTime | setValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00");
ss.info( first_simple_date_time.getWeekOfYearLocalTime() ); // 1 |
Returns the number of the week saved by the SimpleDateTime object, showed in the system time-zone.
Return:
: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 |
Type | Description |
---|
Integer | The number of the current week. |
Example:
Code Block |
---|
language | js |
---|
title | getWeekOfYearUTC |
---|
| js |
---|
theme | Eclipse |
---|
title | subtract #1 |
---|
linenumbers | true |
---|
|
const startDatetimevar first_simple_date_time = new SimpleDateTime("'2019-0111-0108 0820:00:00");');
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffDuration = new SimpleDateTime().subtract(startDatetime, endDatetime);
ss.info( first_simple_date_time.getWeekOfYearUTCdiffDuration.getDurationSeconds() ); |
Returns the year saved by the SimpleDateTime object, showed in the user's time zone.
Return:
Type | Description |
---|
Integer | Four-digit year value. |
Same example without using of the subtract:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
const startDatetime |
Example:
Code Block |
---|
language | js |
---|
title | getYearLocalTime |
---|
|
var first_simple_date_time = new SimpleDateTime("'2019-0111-0108 0820:00:00"');
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
ss.info( first_simple_date_time.getYearLocalTime() |
Returns the year saved by the SimpleDateTime object, showed in the system zone.
Return:
Type | Description |
---|
Integer | Four-digit year value. |
const diffSeconds = endDatetime.getNumericValue() - startDatetime.getNumericValue();
ss.info(diffSeconds);
// Info: 388 |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | true |
---|
|
const datetime |
Example:
Code Block |
---|
language | js |
---|
title | getYearLocalTime |
---|
|
var first_simple_date_time = new SimpleDateTime("2019'2020-0108-0128 0809:00:00");
ss.info( first_simple_date_time.getYearUTC() ); |
This method allows to determine if a specified value is a valid date and time.
Return:
Type | Description |
---|
Boolean | Returns true if value is a valid date and time; otherwise, returns false. |
');
datetime.subtract(3600);
ss.info(datetime.getValue());
//Info: 2020-08-28 08:00:00 |
Same example without using of the subtract
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | isValidtrue |
---|
|
var first_simple_date_timeconst datetime = new SimpleDateTime("2019'2020-0108-0128 0809:00:00"');
first_simple_date_time.setDisplayValue("2011-aa-01 00:00:00"datetime.addSeconds(-3600);
ss.info( first_simple_date_time.isValiddatetime.getValue() ) ;
// falseInfo: 2020-08-28 08:00:00 |