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 | Mandatory | Default Value |
---|
daysdateTime | Integer | YString | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | SimpleDateTime |
---|
linenumbers | trueaddDaysLocalTime |
---|
|
var simple_date_timeconst nowDateTime = new SimpleDateTime();
//
const registrationDateTime = new SimpleDateTime(record.registration_datetime);
//
const yearStartDateTime = 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 | Mandatory | Default Value |
---|
days | integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | addDaysUTC |
---|
|
var simple_date_timeInfo: 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("2019-01-01 08:00:00");
simple_date_time.addDaysUTC(-1)
'yesterday 06:30');
ss.info(simple_date_timeyesterdayWorkdayDayStart.getValue());
// Info: 20182022-1202-3128 0806:0030: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 | Mandatory | Default Value |
---|
months | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | addMonthsLocalTime |
---|
|
var simple_date_time
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("2019-01-01 08:00:00");
simple_date_time.addMonthsLocalTime(1)
`first day of ${monthName}`);
ss.info(simple_date_timerangeStartDatetime .getValue());
// Info: 2019-02-01 |
Adds a specified number of months to the current SimpleDateTime object. The negative 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 values.
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 |
---|
title | addMonthsUTCTime |
---|
|
var simple_date_time2022-02-01 00:00:00
const YEAR = 2022;
const MONTH = 2;
const monthDatetime = new SimpleDateTime("2019-01-01 08:00:00");
simple_date_time.addMonthsUTC(-1)`${YEAR}-${String(MONTH).padStart(2, '0')}-02 00:00:00`);
const monthName = monthDatetime.getMonthUTC();
ss.info(simple_date_time.getValue()); monthName);
// 2018-12-01 08: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 daysAdd a specified number of seconds to the current SimpleDateTime object.
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 | addSeconds | addDays |
---|
linenumbers | true |
---|
|
const registrationDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addSeconds(3600registrationDateTime.addDays(3);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 2019-01-0104 0908:0012:0010 |
addWeeksLocalTimeaddMonths(
weeksmonths)
Adds a specified This method is used to change the number of weeks to months 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 valuesadds months to the object, the negative value diminishes the number of months.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
weeksmonths | integerInteger | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addMonths |
---|
linenumbers | addWeeksLocalTime | true |
---|
|
const registrationDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addWeeksLocalTime(2)registrationDateTime.addMonths(-1);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 20192018-12-01-15 |
addSeconds(seconds)
This method is used to change the number of seconds 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 seconds to the object, the negative value diminishes the number of seconds.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
weeksseconds | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeksUTC | addSeconds |
---|
linenumbers | true |
---|
|
const registrationDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addWeeksUTC(-1)registrationDateTime.addSeconds(3600);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 20182019-1201-2501 0809:0012:0010 |
addYearsLocalTimeaddWeeks(
yearsweeks)
Adds a specified This method is used to change the number of years to weeks in the current SimpleDateTime object according to the local date and time. The negative positive value of the parameter will subtract the years.The 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 valuesadds weeks to the object, the negative value diminishes the number of weeks.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
Yearsweeks | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | addWeeks |
---|
linenumbers | addYearsLocalTimetrue |
---|
|
var simple_date_timeconst registrationDateTime = new SimpleDateTime("'2019-01-01 08:0012:00"10');
simple_date_time.addYearsLocalTimeregistrationDateTime.addWeeks(1);
ss.info(simple_date_timeregistrationDateTime.getValue());
//Info: 2020-01-01 |
addYearsUTCaddYears(years)
Adds a specified This method is used to change the number of years to in the current SimpleDateTime object according to the local date and time. The negative positive value of the parameter will subtract the years.The 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 valuesadds years to the object, the negative value diminishes the number of years.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
Yearsyears | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | addYearsLocalTime |
---|
| theme | Eclipse |
---|
title | addYears |
---|
linenumbers | true |
---|
|
const contractStartDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 0800:00:00"');
simple_date_time.addYearsLocalTimecontractStartDateTime.addYears(1);
ss.info(simple_date_timecontractStartDateTime.getValue());
//Info: 2020-01-01 00:00:00 |
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 falseFALSE.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
Boolean | Returns true 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 | after |
---|
linenumbers | true |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("2019'2018-01-01 0807:0058:00"35');
var second_simple_date_timeconst endDateTime = new SimpleDateTime("2018'2019-01-01 08:00:00"');
letconst resultisStartAfterThanEnd = first_simple_date_timestartDateTime.after(second_simple_date_timeendDateTime);
ss.info(resultisStartAfterThanEnd) ;
//Info: truefalse |
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):
Name | Type | Mandatory | Default Value |
---|
dateTime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
Boolean | Returns true 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 | Eclipsejs |
---|
title | before |
---|
linenumbers | true |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("2019'2018-01-01 0807:0058:00"35');
var second_simple_date_timeconst endDateTime = new SimpleDateTime("2018'2019-01-01 08:00:00"');
letconst resultisStartBeforeEnd = first_simple_date_timestartDateTime.before(second_simple_date_timeendDateTime);
ss.info(resultisStartBeforeEnd) ;
//Info: falsetrue |
compareTo(dateTime)
Compares This method compares two date and time objects to determine whether they are equivalent or notequal 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. |
-1 | Object's date is before the date specified in the parameter. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | compareTo |
---|
linenumbers | true |
---|
|
var first_simple_date_timeconst begin = new SimpleDateTime("2019-01-01 08:00:00");
var second_simple_date_time = new SimpleDateTime("2018-01'2019-04-01 08:0015:00"');
var third_simple_date_timeconst end = new SimpleDateTime("2018'2019-0105-01 0801:00:00"');
ss.info( first_simple_date_timebegin.compareTo(second_simple_date_time) end)); // -1
ss.info( second_simple_date_timeend.compareTo(first_simple_date_time) begin)); // -1
ss.info( third_simple_date_timebegin.compareTo(second_simple_date_time ) begin)); // 0 |
equals(dateTime)
Compares This method compares a datetime with an existing value if 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 | Returns true This method returns TRUE if the date are equal; otherwise, it returns falseFALSE. |
Example:
Code Block |
---|
language | js |
---|
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"');
var third_simple_date_timeconst thirdDateTime = new SimpleDateTime("'2018-01-01 08:00:00"');
ss.info( first_simple_date_timefirstDateTime.equals(second_simple_date_time) secondDateTime)); // 0
ss.info( third_simple_date_timethirdDateTime.equals(second_simple_date_time ) ); // 1firstDateTime));
//Info: false
//Info: true |
getDate()
Returns This method returns the date stored saved by the GlideDateTime SimpleDateTime object , showed 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 startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_timestartDateTime.getDate() );
//Info: 2019-01-01 |
getDaysInMonthLocalTimegetDayOfMonthLocalTime()
Returns This method returns the number day of days in the month saved by the SimpleDateTime object , showed in the current user's time zone.
Return:
Type | Description |
---|
Integer | The |
number days
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthLocalTime | getDaysofMonthsLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDaysInMonthLocalTimeholidayDateTime.getDayOfMonthLocalTime() );
//Info: 317 |
getDayOfMonthLocalTimegetDayOfMonthUTC()
Returns This method returns the day of the month saved by the SimpleDateTime object , showed in the user's 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 holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthLocalTimeholidayDateTime.getDayOfMonthUTC() );
//Info: 17 |
getDayOfMonthUTCgetDayOfWeekLocalTime()
Returns This method returns the day of the month week saved by the SimpleDateTime object , showed in the UTC current user's time zone.
Return:
Integer the month value.week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekLocalTime |
---|
linenumbers | getDaysofMonthsLocalTime | true |
---|
|
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthUTCholidayDateTime.getDayOfWeekLocalTime() ); // Mon |
getDayOfWeekLocalTimegetDayOfWeekUTC()
Returns This method returns the day of the week saved by the SimpleDateTime object , showed in the user's system time zone.
Return:
The day of week value.The day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekUTC |
---|
linenumbers | truegetDayOfWeekLocalTime |
---|
|
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
ss.info( first_simple_date_time.getDayOfWeekLocalTimeholidayDateTime.getDayOfWeekUTC() );
//Info: TueMon |
getDayOfWeekUTCgetDaysInMonthLocalTime()
Returns This method returns the day number of days in the week month saved by the SimpleDateTime object , showed in the system current user's time zone.
Return:
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDayOfWeekUTC | getDaysInMonthLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfWeekUTCstartDateTime.getDaysInMonthLocalTime() );
//Info: 31 |
getDaysInMonthUTC()
Returns This method returns the number of days in the month saved by the SimpleDateTime object , showed in the system time zone.
Return:
Type | Description |
---|
Integer | The number of days value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDaysInMonthUTC |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_timestartDateTime.getDaysInMonthUTC() );
//Info: 31 |
getDisplayValue()
Gets This method returns the date and time value in the current user's display format and timezone.
Return:
Type | Description |
---|
String | The date and time value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getDisplayValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_timestartDateTime.getDisplayValue() ) ; //uses current user session time zone user's timezone is Europe/Moscow
//Info: 2019-01-01 11:00:00 |
getErrorMsg()
Gets This method returns the error message if the SimpleDateTime object was incorrect.
Return:
Type | Description |
---|
String | The error message. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getErrorMsg |
---|
linenumbers | true |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-zz-01 08:00:00"');
ss.info( first_simple_date_timeerror(startDateTime.getErrorMsg());
//Error: DateTimeZone::getOffset() ; //The parsed date or time was invalid!expects parameter 1 to be DateTimeInterface, null given |
getLocalDate()
Returns This method returns the date stored saved by the GlideDateTime SimpleDateTime object , showed in the current user's time zone.
Return:
Type | Description |
---|
String | The date in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalDate |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_timestartDateTime.getLocalDate() ));
//Info: 2019-01-01 |
getLocalTime()
This method returns the time saved in Returns a SimpleDateTime object that shows the time in the current user's time zone .
Return:
Type | Description |
---|
SimpleDateTime | The time in the user's time zone. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
varconst time = first_simple_date_timestartDateTime.getLocalTime();
ss.info( "My local time is " + time.getByFormat('h:mi:s') ) ;);
//Info: My local time is 02:00:00 |
getMonthLocalTime()
Returns This method returns the month saved by SimpleDateTime object , showed in the current user's time zone.
Return:
Type | Description |
---|
String | The value of the month. |
Example:
Code Block |
---|
language | js |
---|
theme | jsEclipse |
---|
title | getMonthLocalTime |
---|
linenumbers | true |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_timestartDateTime.getMonthLocalTime() );
//Info: January |
getMonthUTC()
Returns This method returns the month saved by SimpleDateTime object , showed in the system time zone.
Return:
Type | Description |
---|
String | The value of the month. |
Example:
Code Block |
---|
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_timestartDateTime.getMonthUTC() );
//Info: December |
getNumericValue()
Gets This method returns the Unix timestamp, which stores the amount of milliseconds seconds since January 1, 1970, 00:00:00.
Return:
Type | Description |
---|
Integer | The Unix timestamp value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getNumericValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_timestartDateTime.getNumericValue() ) ;
//Info: 15463188001546329600 |
getTime()
Returns This method returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime object.
Return:
Type | Description |
---|
SimpleDateTime | The Unix duration stamp. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getTime |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
varconst time = first_simple_date_timestartDateTime.getTime();
ss.info( time.getByFormat('h:mi:s') );
//Info: 11:01:00 |
getValue()
Gets This method returns the date and time value in the internal format.
Return:
Type | Description |
---|
null | string | The date and time value in the internal format. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_timestartDateTime.getValue() ); // 2019-01-01 08:00:00 |
getWeekOfYearLocalTime()
Returns the number of This method returns the week saved 's number saved by the SimpleDateTime object , showed in the current user's time - zone.
Return:
Type | Description |
---|
Integer | The number of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearLocalTime |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_timestartDateTime.getWeekOfYearLocalTime() );
//Info: 1 |
getWeekOfYearUTC()
This method returns Returns the number of the week saved by the SimpleDateTime object , showed in the system time - zone.
Return:
Type | Description |
---|
Integer | The number of the current week. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getWeekOfYearUTC |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_timestartDateTime.getWeekOfYearUTC() );
//Info: 1 |
getYearLocalTime()
Returns This method returns the year saved by the SimpleDateTime object , showed in the current user's time zone.
Return:
Type | Description |
---|
Integer | Four-digit year value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearLocalTime |
---|
linenumbers | true |
---|
|
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_timeholidayDateTime.getYearLocalTime()) |
getYearLocalUTCgetYearUTC()
Returns This method returns the year saved by the SimpleDateTime object , showed in the system time zone.
Return:
Type | Description |
---|
Integer | Four-digit year value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getYearLocalTime | getYearUTC |
---|
linenumbers | true |
---|
|
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_timeholidayDateTime.getYearUTC() );
//Info: 2019 |
isValid()
This method allows to determine if a specified value is a valid date and time.
Return:
Type | Description |
---|
Boolean | Returns true if The method returns TRUE if the value is a valid date and time; otherwise, it returns false . |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isValid |
---|
linenumbers | true |
---|
|
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
first_simple_date_time.setDisplayValue("startDateTime.setValue('2011-aa-01 00:00:00"');
ss.info( first_simple_date_time.info(startDateTime.isValid() ) ;
//Info: false |
setDisplayValuesetValue(dateTime
, format)
Sets the dateTime value using the current user's display format and time zone.
This method is intended to define the date and time value within the SimpleDateTime object.
Parameter(s):
| Default Value |
---|
dateTime | A string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss. | Y | N |
Default ValueStringA SimpleDateTime object. | Y | N |
format | 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 |
String'' |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setDisplayValue | setValue |
---|
linenumbers | true |
---|
|
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
first_simple_date_time.setDisplayValue("
startDateTime.setValue('2020-01-01 12:00:00"');
ss.info( first_simple_date_timestartDateTime.getValue() ); |
Sets the date and time of the SimpleDateTime object);
//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):
Type | Mandatory | Default Value | dateTime | A string in the UTC time zone and the internal format of yyyy-MM-dd HH:mm:ss. | Y | N |
dateTime | A SimpleDateTime object | Type | Mandatory | Default Value |
---|
first | SimpleDateTime Object | Y | N |
dateTime | A JavaScript Number. Sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00. | Y | second | SimpleDateTime Object | N | NULL |
N
Return:
Description | Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | setValue |
---|
| theme | Eclipse |
---|
title | subtract #1 |
---|
linenumbers | true |
---|
|
const startDatetimevar first_simple_date_time = new SimpleDateTime("'2019-0111-0108 0820:00:00");
first_simple_date_time.setValue("2020-01-01 12: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.getValuediffDuration.getDurationSeconds() );
// 2020-01-01 12:00:00 |
This method gets the duration between to SimpleDateTime values. Also it can subtract an 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 |
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 |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | subtract #2 |
---|
linenumbers | true |
---|
|
const datetime |
Return:
Type |
---|
SimpleDuration object |
Example:
Code Block |
---|
|
var simple_date_time = new SimpleDateTime("2019'2020-0108-01 08:00:00");
var simple_time = new SimpleTime();
simple_time.setValue("00:00:20");
simple_date_time.subtract(simple_time);
var second_simple_time = simple_date_time.getTime(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( second_simple_time.getByFormat('h:m:s') ); // 2019-01-01 07:59:40datetime.getValue());
//Info: 2020-08-28 08:00:00 |