Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This class provides methods for performing operations on SimpleDateTime objects, such as instantiating objects, for exampleThe class is used to conduct operations on SimpleDateTime objects, for example, instantiating objects.

You can also use this class to perform calculate, change formats of the date-time operations, such as calculations, formatting or converting between date-time or convert between the formats.

addDaysLocalTime

SimpleDateTime(

days

dateTime)

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

daysInteger
NameTypeMandatoryDefault Value
Return:
dateTime
Type
String
Description
N
VoidThis method does not return a value.
''


Example:

Code Block
languagejs
themeEclipse
titleSimpleDateTimeaddDaysLocalTime
linenumberstrue
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
languagejs
themeEclipse
titleSimpleDateTime
linenumberstrue
const yesterdayDatetime = new SimpleDateTime('yesterday');
ss.info(simple_date_timeyesterdayDatetime.getValue()); 
// 2018-12-31

addDaysUTC(days)

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

NameTypedaysinteger

Return:

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


Parameter(s):

NameTypeMandatoryDefault Value
daysintegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddDays
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addDays(3);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-04 08:12:10

addMonths(months)


This method is used to change the number of months in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds months to the object, the negative value diminishes the number of months.


Parameter(s):

NameTypeMandatoryDefault Value
monthsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddMonths
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addMonths(-1);
ss.info(registrationDateTime.getValue());
//Info: 2018-12-01 08:12:10

addSeconds(seconds)


This method is used to change the number of seconds in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds seconds to the object, the negative value diminishes the number of seconds.


Parameter(s):

NameTypeMandatoryDefault Value
secondsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddSeconds
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addSeconds(3600);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-01 09:12:10

addWeeks(weeks)


This method is used to change the number of weeks in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds weeks to the object, the negative value diminishes the number of weeks.


Parameter(s):

NameTypeMandatoryDefault Value
weeksIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeks
linenumberstrue
const registrationDateTime = new SimpleDateTime('2019-01-01 08:12:10');
registrationDateTime.addWeeks(1);
ss.info(registrationDateTime.getValue());
//Info: 2019-01-08 08:12:10

addYears(years)


This method is used to change the number of years in the current SimpleDateTime object according to the local date and time. The positive value of the parameter adds years to the object, the negative value diminishes the number of years.


Parameter(s):

NameTypeMandatoryDefault Value
yearsIntegerYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddYears
linenumberstrue
const contractStartDateTime = new SimpleDateTime('2019-01-01 00:00:00');
contractStartDateTime.addYears(1);
ss.info(contractStartDateTime.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 FALSE.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
BooleanThe method returns TRUE if the current date is later than the date specified by the parameter; otherwise, returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleafter
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('2019-01-01 08:00:00');
const isStartAfterThanEnd = startDateTime.after(endDateTime);
ss.info(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 false.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
BooleanThe method returns TRUE if the current date is earlier than the date specified by the parameter; otherwise, returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titlebefore
linenumberstrue
const startDateTime = new SimpleDateTime('2018-01-01 07:58:35');
const endDateTime = new SimpleDateTime('

Example:

Code Block
languagejs
titleaddDaysUTC
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

addMonthsLocalTime(months)

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

NameTypemonthsInteger

Return:

TypeDescriptionVoidThis method does not return a value.
const isStartBeforeEnd = startDateTime.before(endDateTime);
ss.info(isStartBeforeEnd);
//Info: true

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

NameTypeMandatoryDefault Value
dateTimeSimpleDateTime objectYN


Return:

TypeDescription
0Dates are equal.
1Object's date is after the date specified in the parameter.
-1Object's date is before the date specified in the parameter.


Example:

Code Block
languagejs
themeEclipse
titlecompareTo
linenumberstrue
const begin = new SimpleDateTime('2019-04-01 08:15:00');
const end

Example:

Code Block
languagejs
titleaddMonthsLocalTime
var simple_date_time = new SimpleDateTime("'2019-0105-01 0801:00:00"');
simple_date_time.addMonthsLocalTime(1)
ss.info(begin.compareTo(end));   // -1
ss.info(end.compareTo(begin));   // 1
ss.info(simple_date_time.getValue(begin.compareTo(begin)); // 2019-02-01

addMonthsUTC(months)

Adds a specified number of months to the current SimpleDateTime object. The negative value of the parameter will subtract the months.

0

equals(dateTime)


This method compares a datetime with an existing value to determine whether they are equal or notThe 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):

Integer
NameTypemonthsMandatoryDefault Value
dateTimeSimpleDateTime object.YN


Return:

TypeDescription
Void
BooleanThis method
does not return a value
returns TRUE if the date are equal; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titleaddMonthsUTCTimeequals
linenumberstrue
const firstDateTimevar simple_date_time = new SimpleDateTime("2019'2018-01-01 08:00:00"');
simple_date_time.addMonthsUTC(-1)
ss.info(simple_date_time.getValue()); // 2018-12-01 08:00:00

addSeconds(seconds)

Add a specified number of seconds to the current SimpleDateTime object.

Parameter(s):

NameTypesecondsInteger

Return:

TypeDescriptionVoidThis method does not return a value.

Example:

Code Block
languagejs
titleaddSeconds
var simple_date_timeconst secondDateTime = new SimpleDateTime('2018-01-01 08:15:00');
const thirdDateTime = new SimpleDateTime("2019'2018-01-01 08:00:00"');
simple_date_time.addSeconds(3600

ss.info(firstDateTime.equals(secondDateTime));
ss.info(simple_date_time.getValue(thirdDateTime.equals(firstDateTime));
//Info: false
// 2019-01-01 09:00:00

addWeeksLocalTime(weeks)

Adds a specified number of weeks to the current SimpleDateTime object. The negative 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.

Parameter(s):

NameTypeweeksinteger
Info: true

getDate()


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


Return:

TypeDescription
VoidThis method does not return a value
StringThe date in the default timezone.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeksLocalTimegetDate
linenumberstrue
const startDateTimevar simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
simple_date_time.addWeeksLocalTime(2)
ss.info(simple_date_time.getValuestartDateTime.getDate()); 
//Info: 2019-01-1501
addWeeksUTC

getDayOfMonthLocalTime(

weeks

)

Adds a specified number of weeks to the current SimpleDateTime object. The negative 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 values.

Parameter(s):

NameTypeweeksInteger

This method returns the day of the month saved by the SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
VoidThis method does not return a
IntegerThe day of the month value.


Example:

Code Block
languagejs
themeEclipse
titleaddWeeksUTCgetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTimevar simple_date_time = new SimpleDateTime("'2019-01-0107 08:00:00"');
simple_date_time.addWeeksUTC(-1)
ss.info(simple_date_time.getValueholidayDateTime.getDayOfMonthLocalTime()); 
// 2018-12-25 08:00:00

addYearsLocalTime(years)

Adds a specified number of years to the current SimpleDateTime object. The negative value of the parameter will subtract the years.

The method determines local date and time equivalent to the value saved by the GlideDateTime object, then adds or subtracts the years using local date and time values.

Parameter(s):

NameTypeYearsInteger
Info: 7

getDayOfMonthUTC()


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


Return:

TypeDescription
VoidThis method does not return a
IntegerThe day of the month value.


Example:

Code Block
languagejs
titleaddYearsLocalTime
themeEclipse
titlegetDaysofMonthsLocalTime
linenumberstrue
const holidayDateTimevar simple_date_time = new SimpleDateTime("'2019-01-0107 08:00:00"');
simple_date_time.addYearsLocalTime(1)
ss.info(simple_date_time.getValueholidayDateTime.getDayOfMonthUTC()); 
// 2020-01-01

addYearsUTC(years)

Adds a specified number of years to the current SimpleDateTime object. The negative 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 values.

Parameter(s):

NameTypeYearsInteger
Info: 7

getDayOfWeekLocalTime()


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


Return:

TypeDescription
VoidThis method does not return a value.
StringThe day of week value. Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTime
linenumberstrueaddYearsLocalTime
var simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-01-0107 08:00:00"');
simple_date_time.addYearsLocalTime(1)
ss.info(simple_date_time.getValueholidayDateTime.getDayOfWeekLocalTime()); // 2020-01-01
after(dateTime
Mon

getDayOfWeekUTC()


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

Parameter(s):

NameTypedateTimeSimpleDateTime object

returns the day of the week saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
BooleanReturns true if the current date is later than the date specified by the parameter.
StringThe day of week value.
Possible values: 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTCafter
linenumberstrue
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-0107 08:00:00"');
var second_simple_date_time = new SimpleDateTime("2018-01-01 08:00:00");
let result = first_simple_date_time.after(second_simple_date_time);
ss.info(result) // true

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

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

TypeDescription
BooleanReturns true if the current date is earlier than the date specified by the parameter
IntegerThe number of days value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthLocalTimebefore
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
var second_simple_date_time = new SimpleDateTime("2018'2019-01-01 08:00:00");
let result = first_simple_date_time.before(second_simple_date_time);
ss.info(result) // false

compareTo(dateTime)

Compares two date and time objects to determine whether they are equivalent or not.

Parameter(s):

NameTypedateTimeSimpleDateTime object
');
ss.info(startDateTime.getDaysInMonthLocalTime());
//Info: 31

getDaysInMonthUTC()


This method returns the number of days in the month saved by the SimpleDateTime object in the system time zone.


Return:

TypeDescription
IntegerThe number of days value

Return:

TypeDescription0Dates are equal1Object's date is after the date specified in the parameter.-1Object's date is before the date specified in the parameter
.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTC
linenumberscompareTotrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
var second_simple_date_time = new SimpleDateTime("2018'2019-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

equals(dateTime)

Compares a datetime with an existing value if they are equal.

Parameter(s):

NameType
');
ss.info(startDateTime.getDaysInMonthUTC());
//Info: 31

getDisplayValue()


This method returns the date and time value in the current user's display format and timezone.


Return:

TypeDescription
StringThe date and time value.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValue
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(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 incorrect

dateTimeSimpleDateTime object

.


Return:

TypeDescription
BooleanReturns true if the date are equal; otherwise returns false
StringThe error message.


Example:

Code Block
languagejs
themeEclipse
titleequalsgetErrorMsg
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01zz-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

getDate()

');
ss.error(startDateTime.getErrorMsg());
//Error: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given

getLocalDate()


This method returns the date saved by the SimpleDateTime object in the current user's time zone.


Return:

TypeDescription
StringThe date in the user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalDate
linenumberstrue
const startDateTime = new SimpleDateTime('2019-01-01 08:00:00');
ss.info(startDateTime.getLocalDate());
//Info: 2019-01-01

getLocalTime()


This method returns the time saved in a SimpleDateTime object in the current user's Returns the date stored by the GlideDateTime object, showed in the system time zone .


Return:

TypeDescription
String
SimpleDateTimeThe
date
time in the
default timezone
user's time zone.


Example:

Code Block
languagejs
themeEclipse
titlegetLocalTime
linenumberstruegetDate
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
const time = startDateTime.getLocalTime();
ss.info( first_simple_date_time.getDate() ); // 2019-01-01

getDaysInMonthLocalTime()

 "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 Returns the number of days in the month saved by the SimpleDateTime object, showed in the user's time zone.


Return:

TypeDescription
Integer
StringThe
number
value of
days value
the month.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthLocalTime
linenumbersgetDaysInMonthLocalTimetrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getDaysInMonthLocalTimestartDateTime.getMonthLocalTime() ); 
//Info: 31January
getDayOfMonthLocalTime

getMonthUTC()


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


Return:

TypeDescription
Integer
StringThe
day
value of the month
value
.


Example:

Code Block
languagejs
titlegetDaysofMonthsLocalTime
themeEclipse
titlegetMonthUTC
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getDayOfMonthLocalTimestartDateTime.getMonthUTC() ); 
//Info: 1December
getDayOfMonthUTC

getNumericValue()


Returns the day of the month saved by the SimpleDateTime object, showed in the UTC time zoneThis method returns the Unix timestamp, which stores the amount of seconds since January 1, 1970, 00:00:00.


Return:

TypeDescription
IntegerThe
day of the month
Unix timestamp value.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysofMonthsLocalTimegetNumericValue
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfMonthUTC() );

getDayOfWeekLocalTime()

startDateTime.getNumericValue());
//Info: 1546329600

getTime()


This method returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime objectReturns the day of the week saved by the SimpleDateTime object, showed in the user's time zone.


Return:

TypeDescription
String
SimpleDateTimeThe
day of week value
Unix duration stamp.


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekLocalTimegetTime
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"00');
const time = startDateTime.getTime();
ss.info( first_simple_date_time.getDayOfWeekLocalTime() getByFormat('h:i:s')); 
// Tue
getDayOfWeekUTC
Info: 11:01:00

getValue()


Returns the day of the week saved by the SimpleDateTime object, showed in the system time zoneThis method returns the date and time value in the internal format.


Return:

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


Example:

Code Block
languagejs
themeEclipse
titlegetDayOfWeekUTCgetValue
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00"');
ss.info( first_simple_date_time.getDayOfWeekUTCstartDateTime.getValue() );
getDaysInMonthUTC
 // 2019-01-01 08:00:00

getWeekOfYearLocalTime()


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


Return:

TypeDescription
IntegerThe number of
days value
the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetDaysInMonthUTCgetWeekOfYearLocalTime
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getDaysInMonthUTC() );

getDisplayValue()

startDateTime.getWeekOfYearLocalTime());
//Info: 1

getWeekOfYearUTC()


This method returns the number of the week saved by the SimpleDateTime object in the system time zoneGets the date and time value in the current user's display format and timezone.


Return:

TypeDescription
Null | String
IntegerThe number of the current week.


Example:

Code Block
languagejs
themeEclipse
titlegetWeekOfYearUTC
linenumberstruegetDisplayValue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getDisplayValuestartDateTime.getWeekOfYearUTC() ) ; 
//uses current user session time zone
getErrorMsg
Info: 1

getYearLocalTime()


Gets the error message if This method returns the year saved by the SimpleDateTime object was incorrectin the current user's time zone.


Return:

TypeDescription
StringThe error message
IntegerFour-digit year value.


Example:

Code Block
languagejs
titlegetErrorMsg
themeEclipse
titlegetYearLocalTime
linenumberstrue
const holidayDateTimevar first_simple_date_time = new SimpleDateTime("'2019-zz12-0131 0823:0045:00"');
ss.info( first_simple_date_time.getErrorMsgholidayDateTime.getYearLocalTime() ) ;  
//The parsed date or time was invalid!
getLocalDate
Info: 2020

getYearUTC()


Returns the date stored This method returns the year saved by the GlideDateTime SimpleDateTime object , showed in the user's system time zone.


Return:

TypeDescription
StringThe date in the user's time zone
IntegerFour-digit year value.


Example:

Code Block
languagejs
themeEclipse
titlegetYearUTC
linenumberstruegetLocalDate
var first_simple_date_timeconst holidayDateTime = new SimpleDateTime("'2019-0112-0131 0823:0045:00"');
ss.info( first_simple_date_time.getLocalDate() )

getLocalTime()

holidayDateTime.getYearUTC()); 
//Info: 2019

isValid()


This method allows to determine if a specified value is a valid date and timeReturns a SimpleDateTime object that shows the time in the user's time zone.


Return:

TypeDescription
SimpleDateTime
BooleanThe
time in the user's time zone
method returns TRUE if the value is a valid date and time; otherwise, it returns .


Example:

Code Block
languagejs
themeEclipse
titleisValid
linenumbersgetLocalTimetrue
var first_simple_date_timeconst startDateTime = new SimpleDateTime("'2019-01-01 08:00:00"');
var time = first_simple_date_time.getLocalTime(startDateTime.setValue('2011-aa-01 00:00:00');
ss.info( "My local time is " + time.getByFormat('h:m:s') ) ;

getMonthLocalTime()

Returns the month saved by SimpleDateTime object, showed in the current user's time zone.

Return:

TypeDescriptionStringThe value of the month.

Example:

Code Block
languagejs
titlegetMonthLocalTime
var first_simple_date_time = new SimpleDateTime("2019-01-01 08:00:00");
ss.info( first_simple_date_time.getMonthLocalTime() ); // January

getMonthUTC()

Returns the month saved by SimpleDateTime object, showed in the system time zone.
startDateTime.isValid());
//Info: false

setValue(dateTime)


This method is intended to define the date and time value within the SimpleDateTime object.


Parameter(s):

NameTypeMandatoryDefault Value
dateTimeA string in the UTC timezone and the internal format of YYYY-MM-DD hh:mm:ss.YN
dateTimeA SimpleDateTime object.YN
dateTimeA JavaScript Number. It sets the value of the object using the Number value as milliseconds past January 1, 1970, 00:00:00.YN


Return:

TypeDescription
StringThe value of the month
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlegetMonthUTCsetValue
linenumberstrue
const startDateTimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00");
ss.info( first_simple_date_time.getMonthUTC() );

getNumericValue()

Gets the timestamp which stores the amount of milliseconds since January 1, 1970, 00
 08:00:00
.

Return:

TypeDescriptionIntegerThe timestamp

Example:

Code Block
languagejs
titlegetNumericValue
var first_simple_date_time = new SimpleDateTime("2019');
startDateTime.setValue('2020-01-01 12:00:00');
ss.info(startDateTime.getValue());
//Info: 2020-01-01 0812:00:00");
ss.info( first_simple_date_time.getNumericValue() ) ; // 1546318800

getTime()

Returns a SimpleDateTime object that shows the piece of time of the SimpleDateTime object.

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

NameTypeMandatoryDefault Value
first

SimpleDateTime Object

YN
secondSimpleDateTime ObjectNNULL


Return:

TypeDescription
SimpleDateTimeThe Unix duration stamp.
SimpleDuration object


Example:

Code Block
languagejs
themeEclipse
titlegetTimesubtract #1
linenumberstrue
const startDatetimevar first_simple_date_time = new SimpleDateTime("'2019-01-01 08:00:00");
var time = first_simple_date_time.getTime();11-08 20:00:00');
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffDuration = new SimpleDateTime().subtract(startDatetime, endDatetime); 
ss.info( timediffDuration.getByFormat('h:m:s') );

getValue()

Gets the date and time value in the internal format.

Return:

TypeDescriptionnull | stringThe date and time value in the internal format
getDurationSeconds());
// Info: 388

Same example without using of the subtract

Example

:

Code Block
languagejs
titlegetValue
themeEclipse
linenumberstrue
const startDatetimevar first_simple_date_time = new SimpleDateTime("'2019-0111-0108 0820:00:00"');
ss.info( first_simple_date_time.getValue() ); //2019-01-01 08:00:00

getWeekOfYearLocalTime()

Returns the number of the week saved by the SimpleDateTime object, showed in the user's time-zone.

Return:

TypeDescriptionIntegerThe number of the current week.Example:
const endDatetime = new SimpleDateTime('2019-11-08 20:06:28');
const diffSeconds = endDatetime.getNumericValue() - startDatetime.getNumericValue(); 
ss.info(diffSeconds);
// Info: 388


Code Block
languagejs
themeEclipse
titlegetWeekOfYearLocalTimesubtract #2
linenumberstrue
const datetimevar first_simple_date_time = new SimpleDateTime("2019'2020-0108-0128 0809:00:00"');
datetime.subtract(3600);
ss.info( first_simple_date_time.getWeekOfYearLocalTimedatetime.getValue() ); 
// 1

getWeekOfYearUTC()

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

Return:

TypeDescriptionIntegerThe number of the current week.
Info: 2020-08-28 08:00:00

Same example without using of the subtract:

Code Block
languagejs
themeEclipse
titlesubtract #2
linenumberstrue
const datetime

Example:

Code Block
languagejs
titlegetWeekOfYearUTC
var first_simple_date_time = new SimpleDateTime("2019'2020-0108-0128 0809:00:00"');
datetime.addSeconds(-3600);
ss.info( first_simple_date_time.getWeekOfYearUTCdatetime.getValue() );
//Info: 2020-08-28 08:00:00


Table of Contents
classabsoluteUrlfixedPositiontrue