---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideDateTime - Scoped

# GlideDateTime - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 26 minutes to read

The scoped GlideDateTime class provides methods for performing operations on GlideDateTime objects.

Use the GlideDateTime methods to perform date-time operations, such as instantiating a GlideDateTime object, performing date-time calculations, formatting a date-time, or converting between date-time formats.

For guidance on date time input strings with a list of common format conflicts, refer to [Date and time format guidelines](https://servicenow-prod.fluidtopics.net/RgXT711o4n9v_sJ0uKmMsA#date-and-time-format-guidelines "You can specify a date format with a sequence of specific date and time pattern strings. A pattern string consists of one or more uppercase and lowercase letters from A to Z. Any text within quotation marks is ignored and is instead copied into the date output.").

## Scoped GlideDateTime - GlideDateTime() {#ariaid-title2}

Instantiates a new GlideDateTime object with the current date and time.
{#r_ScopedGlideDateTimeGlideDateTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#r_ScopedGlideDateTimeGlideDateTime__table_vy2_525_jq}  
This example instantiates a GlideDateTime object.

    var gdt = new GlideDateTime();
    gs.info(gdt);

Output:

    2022-08-08 16:51:44

## Scoped GlideDateTime - GlideDateTime(String value) {#ariaid-title3}

Instantiates a new GlideDateTime object using the passed-in date and time value.
The system attempts to match the passed-in value with the specified internal system format. If the argument does not match the system format, the system attempts to match it to one of the following formats in this order:

* yyyy-MM-dd HH:mm:ss
* MM/dd/yyyy HH:mm:ss
* MM-dd-yyyy HH:mm:ss
* MM-dd-yyyy HH:mm
* MM-dd-yyyy
* MM/dd/yyyy
* dd-MM-yyyy HH:mm:ss
* dd-MM-yyyy HH.mm.ss
* dd-MM-yyyy HH.mm
* dd-MM-yy HH.mm.ss
* dd/MM/yyyy
* dd-MM-yyyy
* yyyy-MM-dd HH:mm
* yyyy-MM-dd
* dd.MM.yyyy HH:mm:ss
* dd.MM.yyyy HH.mm.ss
* dd.MM.yyyy hh:mm:ss a
* dd.MM.yyyy hh.mm.ss a
* dd.MM.yyyy

{#r_ScopedGlideDateTimeGlideDateTime_String_value__ul_xgq_hmz_lnb}  
Note:  
The following format is not supported:

* yyyy-MM-dd'T'HH:mm:ss.SSSZ
{#r_ScopedGlideDateTimeGlideDateTime_String_value__ul_udg_d5w_lcc}
{#r_ScopedGlideDateTimeGlideDateTime_String_value__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| value | String | UTC date and time to set in the GlideDateTime object. |
[Table 2. Parameters]

{#r_ScopedGlideDateTimeGlideDateTime_String_value__table_vy2_525_jq}  
This example shows how to instantiate a GlideDateTime object using a string.

    var gdt = new GlideDateTime("2023-01-01 12:00:00");
    gs.info(gdt);

Output:

    2023-01-01 12:00:00

## Scoped GlideDateTime - GlideDateTime(GlideDateTime g) {#ariaid-title4}

Instantiates a new GlideDateTime object set to the time of a specified GlideDateTime object.
{#r_ScopedGlideDateTimeGlideDateTime_GlideDateTime_g__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| g | GlideDateTime | Object used to set the time of the new object. |
[Table 3. Parameters]

{#r_ScopedGlideDateTimeGlideDateTime_GlideDateTime_g__table_vy2_525_jq}  
This example shows how to instantiate a GlideDateTime object (gdt1) using a string in the format `yyyy-MM-dd HH:mm:ss`, and a second GlideDateTime object (gdt2) using
gdt1.

    var gdt1 = new GlideDateTime("2025-01-28 12:00:00"); // GlideDateTime(String g)
    var gdt2 = new GlideDateTime(gdt1); // GlideDateTime(GlideDateTime g)
    gs.info(gdt1);
    gs.info(gdt2);

Output:

    2025-01-28 12:00:00
    2025-01-28 12:00:00

## Scoped GlideDateTime - add(GlideTime gd) {#ariaid-title5}

Adds a GlideTime object to the current GlideDateTime object.
{#r_ScopedGlideDateTimeAdd_GlideTime_gd__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| gd | GlideTime | GlideTime object whose time value to add to the specified GlideDateTime object. |
[Table 4. Parameters]

{#r_ScopedGlideDateTimeAdd_GlideTime_gd__table_vy2_525_jq} {#r_ScopedGlideDateTimeAdd_GlideTime_gd__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 5. Returns]

{#r_ScopedGlideDateTimeAdd_GlideTime_gd__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    var gtime1 = new GlideTime();
    gtime1.setValue("00:00:20");
    gdt.add(gtime1);
    var gtime2 = gdt.getTime();
    gs.info(gtime2.getByFormat('hh:mm:ss'));

Output:

    08:00:20

## Scoped GlideDateTime - add(Number milliseconds) {#ariaid-title6}

Adds the specified number of milliseconds to the current GlideDateTime object.
{#r_ScopedGlideDateTimeAdd_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| milliseconds | Number | The number of milliseconds to add. |
[Table 6. Parameters]

{#r_ScopedGlideDateTimeAdd_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAdd_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 7. Returns]

{#r_ScopedGlideDateTimeAdd_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.getNumericValue());
    gdt.add(10);
    gs.info(gdt.getNumericValue());

Output:

    1314777600000 1314777600010

## Scoped GlideDateTime - addDaysLocalTime(Number days) {#ariaid-title7}

Adds a specified number of days to the current GlideDateTime object. A negative
parameter subtracts days. The method determines the local date and time equivalent to the value
stored by the GlideDateTime object, then adds or subtracts days using the local date and time
values.
{#r_ScopedGlideDateTimeAddDaysLocalTime_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| days | Number | The number of days to add. Use a negative value to subtract. |
[Table 8. Parameters]

{#r_ScopedGlideDateTimeAddDaysLocalTime_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddDaysLocalTime_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 9. Returns]

{#r_ScopedGlideDateTimeAddDaysLocalTime_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gdt.addDaysLocalTime(-1);
    gs.info(gdt.getLocalDate());

Output:

    2011-08-30

## Scoped GlideDateTime - addDaysUTC(Number days) {#ariaid-title8}

Adds a specified number of days to the current GlideDateTime object. A negative
parameter subtracts days. The method determines the UTC date and time equivalent to the value
stored by the GlideDateTime object, then adds or subtracts days using the UTC date and time
values.
{#r_ScopedGlideDateTimeAddDaysUTC_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| days | Number | The number of days to add. Use a negative number to subtract. |
[Table 10. Parameters]

{#r_ScopedGlideDateTimeAddDaysUTC_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddDaysUTC_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 11. Returns]

{#r_ScopedGlideDateTimeAddDaysUTC_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gdt.addDaysUTC(-1);
    gs.info(gdt.getDate());

Output:

     2011-08-30

## Scoped GlideDateTime - addMonthsLocalTime(Number months) {#ariaid-title9}

Adds a specified number of months to the current GlideDateTime object. A negative
parameter subtracts months. The method determines the local date and time equivalent to the
value stored by the GlideDateTime object, then adds or subtracts months using the local date and
time values.
{#r_ScopedGlideDateTimeAddMonthsLocalTime_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| months | Number | The number of months to add. use a negative value to subtract. |
[Table 12. Parameters]

{#r_ScopedGlideDateTimeAddMonthsLocalTime_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddMonthsLocalTime_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 13. Returns]

{#r_ScopedGlideDateTimeAddMonthsLocalTime_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gdt.addMonthsLocalTime(2);
    gs.info(gdt.getDate());

Output:

    2011-10-31

## Scoped GlideDateTime - addMonthsUTC(Number months) {#ariaid-title10}

Adds a specified number of months to the current GlideDateTime object. A negative
parameter subtracts months. The method determines the UTC date and time equivalent to the value
stored by the GlideDateTime object, then adds or subtracts months using the UTC date and time
values.
{#r_ScopedGlideDateTimeAddMonthsUTC_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| months | Number | The number of months to add. Use a negative value to subtract. |
[Table 14. Parameters]

{#r_ScopedGlideDateTimeAddMonthsUTC_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddMonthsUTC_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 15. Returns]

{#r_ScopedGlideDateTimeAddMonthsUTC_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gdt.addMonthsUTC(2);
    gs.info(gdt.getDate());

Output:

    2011-10-31

## Scoped GlideDateTime - addSeconds(Number seconds) {#ariaid-title11}

Adds the specified number of seconds to the current GlideDateTime object.
{#r_ScopedGlideDateTimeAddSeconds_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| seconds | Number | The number of seconds to add. |
[Table 16. Parameters]

{#r_ScopedGlideDateTimeAddSeconds_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddSeconds_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 17. Returns]

{#r_ScopedGlideDateTimeAddSeconds_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-07 08:00:00");
    gdt.addSeconds(1000);
    gs.info(gdt.getValue());

Output:

    2011-12-07 08:16:40

## Scoped GlideDateTime - addWeeksLocalTime(Number weeks) {#ariaid-title12}

Adds a specified number of weeks to the current GlideDateTime object. A negative
parameter subtracts weeks. The method determines the local date and time equivalent to the value
stored by the GlideDateTime object, then adds or subtracts weeks using the local date and time
values.
{#r_ScopedGlideDateTimeAddWeeksLocalTime_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| weeks | Number | The number of weeks to add. Use a negative value to subtract. |
[Table 18. Parameters]

{#r_ScopedGlideDateTimeAddWeeksLocalTime_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddWeeksLocalTime_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 19. Returns]

{#r_ScopedGlideDateTimeAddWeeksLocalTime_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gdt.addWeeksLocalTime(-1);
    gs.info(gdt.getDate());

Output:

    2011-08-24

## Scoped GlideDateTime - addWeeksUTC(Number weeks) {#ariaid-title13}

Adds a specified number of weeks to the current GlideDateTime object. A negative
parameter subtracts weeks. The method determines the UTC date and time equivalent to the value
stored by the GlideDateTime object, then adds or subtracts weeks using the UTC date and time
values.
{#r_ScopedGlideDateTimeAddWeeksUTC_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| weeks | Number | The number of weeks to add. Use a negative value to subtract. |
[Table 20. Parameters]

{#r_ScopedGlideDateTimeAddWeeksUTC_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddWeeksUTC_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 21. Returns]

{#r_ScopedGlideDateTimeAddWeeksUTC_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gdt.addWeeksUTC(-1);
    gs.info(gdt.getDate());

Output:

    2011-08-24

## Scoped GlideDateTime - addYearsLocalTime(Number years) {#ariaid-title14}

Adds a specified number of years to the current GlideDateTime object. A negative
parameter subtracts years. The method determines the local date and time equivalent to the value
stored by the GlideDateTime object, then adds or subtracts years using the local date and time
values.
{#r_ScopedGlideDateTimeAddYearsLocalTime_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| years | Number | The number of years to add. Use a negative value to subtract. |
[Table 22. Parameters]

{#r_ScopedGlideDateTimeAddYearsLocalTime_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddYearsLocalTime_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 23. Returns]

{#r_ScopedGlideDateTimeAddYearsLocalTime_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2010-08-31 08:00:00");
    gdt.addYearsLocalTime(1);
    gs.info(gdt.getDate());

Output:

    2011-08-31

## Scoped GlideDateTime - addYearsUTC(Number years) {#ariaid-title15}

Adds a specified number of years to the current GlideDateTime object. A negative
parameter subtracts years. The date and time value stored by GlideDateTime object is interpreted
as being in the UTC time zone.
{#r_ScopedGlideDateTimeAddYearsUTC_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| years | Number | The number of years to add. Use a negative value to subtract. |
[Table 24. Parameters]

{#r_ScopedGlideDateTimeAddYearsUTC_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeAddYearsUTC_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 25. Returns]

{#r_ScopedGlideDateTimeAddYearsUTC_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2010-08-31 08:00:00");
    gdt.addYearsUTC(1);
    gs.info(gdt.getDate());

Output:

    2011-08-31

## Scoped GlideDateTime - after(GlideDateTime gdt) {#ariaid-title16}

Determines if the GlideDateTime object's date and time occurs after the specified
object's date and time.
{#r_SGDT-after_GDT__table_op2_nqq_yv__entry__3}

| Name | Type | Description |
|-|-|-|
| gdt | GlideDateTime | Date and time to check against. |
[Table 26. Parameters]

{#r_SGDT-after_GDT__table_op2_nqq_yv} {#r_SGDT-after_GDT__table_pp2_nqq_yv__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the GlideDateTime object's date and time is after the date and time specified by the parameter. Possible values: * true: GlideDateTime object date and time is after the specified object's date and time. * false: GlideDateTime object date and time is before or equal to the specified object's date and time. {#r_SGDT-after_GDT__ul_xcn_m2j_zpb} |
[Table 27. Returns]

{#r_SGDT-after_GDT__table_pp2_nqq_yv}  

    var gdt1 = new GlideDateTime("2016-05-09 10:11:12");
    var gdt2 = new GlideDateTime("2017-06-12 15:11:12");
    gs.info(gdt1.after(gdt2)); 

Output:

    False

## Scoped GlideDateTime - before(GlideDateTime gdt) {#ariaid-title17}

Determines if the GlideDateTime object's date and time occurs before the specified
GlideDateTime object's date and time.
{#r_SGDT-before_GDT__table_j5h_vrq_yv__entry__3}

| Name | Type | Description |
|-|-|-|
| gdt | GlideDateTime | Date and time to check against. |
[Table 28. Parameters]

{#r_SGDT-before_GDT__table_j5h_vrq_yv} {#r_SGDT-before_GDT__table_k5h_vrq_yv__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the GlideDateTime object's date and time is before the date and time specified by the parameter. Possible values: * true: GlideDateTime object date and time is before the specified date and time. * false: GlideDateTime object date and time is after or equal to the specified date and time. {#r_SGDT-before_GDT__ul_xcn_m2j_zpb} |
[Table 29. Returns]

{#r_SGDT-before_GDT__table_k5h_vrq_yv}  

    var gdt1 = new GlideDateTime("2016-05-09 10:11:12");
    var gdt2 = new GlideDateTime("2017-06-12 15:11:12");
    gs.info(gdt1.before(gdt2));  

Output

    true

## Scoped GlideDateTime - compareTo(Object o) {#ariaid-title18}

Compares two date and time objects to determine whether they are equivalent or one
occurs before or after the other.
{#r_ScopedGlideDateTimeCompareTo_Object_o__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| o | Object | Date and time object in GlideDateTime format |
[Table 30. Parameters]

{#r_ScopedGlideDateTimeCompareTo_Object_o__table_vy2_525_jq} {#r_ScopedGlideDateTimeCompareTo_Object_o__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | * 0 = Dates are equal * 1 = The object's date is after the date specified in the parameter * -1 = The object's date is before the date specified in the parameter {#r_ScopedGlideDateTimeCompareTo_Object_o__ul_tb3_mjg_sz} |
[Table 31. Returns]

{#r_ScopedGlideDateTimeCompareTo_Object_o__table_qpt_3f5_jq}  

    var initDate = new GlideDateTime("2011-08-01 12:00:00");
    var compDate1 = new GlideDateTime("2011-08-01 12:00:00");
    var compDate2 = new GlideDateTime("2011-07-31 12:00:00");
    var compDate3 = new GlideDateTime("2011-08-04 16:00:00");
     
    gs.info(initDate.compareTo(compDate1)); // Equals (0)
    gs.info(initDate.compareTo(compDate2)); // initDate is after compDate2 (1)
    gs.info(initDate.compareTo(compDate3)); // initDate is before compDate3 (-1)

Output:

    0
    1
    -1

## Scoped GlideDateTime - equals(Object dateTime) {#ariaid-title19}

Compares a datetime with an existing value for equality.
{#r_ScopedGlideDateTimeEquals_Object__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| dateTime | GlideDateTime object or String | The datetime to compare. |
[Table 32. Parameters]

{#r_ScopedGlideDateTimeEquals_Object__table_vy2_525_jq} {#r_ScopedGlideDateTimeEquals_Object__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns true if they are equal; otherwise, false. |
[Table 33. Returns]

{#r_ScopedGlideDateTimeEquals_Object__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 00:00:00");
    gs.info(gdt.equals("2011-09-30 00:12:01"));

Output:

    false

## Scoped GlideDateTime - getDate() {#ariaid-title20}

Returns the date stored by the GlideDateTime object. Expressed in the standard format,
yyyy-MM-dd, and in the system time zone, GMT by default.
{#r_ScopedGlideDateTimeGetDate__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 34. Parameters]

{#r_ScopedGlideDateTimeGetDate__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDate__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Object | Date in the system time zone. |
[Table 35. Returns]

{#r_ScopedGlideDateTimeGetDate__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.getDate());

Output:

    2011-08-31

## Scoped GlideDateTime - getDayOfMonthLocalTime() {#ariaid-title21}

Gets the day of the month stored by the GlideDateTime object, expressed in the current
user's time zone.
{#r_ScopedGlideDateTimeGetDayOfMonthLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 36. Parameters]

{#r_ScopedGlideDateTimeGetDayOfMonthLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDayOfMonthLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The day of the month in the user's time zone, from 1 to 31. |
[Table 37. Returns]

{#r_ScopedGlideDateTimeGetDayOfMonthLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-02 12:00:00");
    gs.info(gdt.getDayOfMonthLocalTime());

Output:

    2

## Scoped GlideDateTime - getDayOfMonthUTC() {#ariaid-title22}

Gets the day of the month stored by the GlideDateTime object, expressed in the UTC time
zone.
{#r_ScopedGlideDateTimeGetDayOfMonthUTC__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 38. Parameters]

{#r_ScopedGlideDateTimeGetDayOfMonthUTC__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDayOfMonthUTC__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The day of the month in the UTC time zone, from 1 to 31. |
[Table 39. Returns]

{#r_ScopedGlideDateTimeGetDayOfMonthUTC__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-02 12:00:00");
    gs.info(gdt.getDayOfMonthUTC());

Output:

    02

## Scoped GlideDateTime - getDayOfWeekLocalTime() {#ariaid-title23}

Gets the day of the week stored by the GlideDateTime object, expressed in the user's
time zone.
{#r_ScopedGlideDateTimeGetDayOfWeekLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 40. Parameters]

{#r_ScopedGlideDateTimeGetDayOfWeekLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDayOfWeekLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The day of week value, in the user's time zone, from 1 to 7. Monday equals 1, Sunday equals 7. |
[Table 41. Returns]

{#r_ScopedGlideDateTimeGetDayOfWeekLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-01 12:00:00");//Thursday
    gs.info(gdt.getDayOfWeekLocalTime());

Output:

    4

## Scoped GlideDateTime - getDayOfWeekUTC() {#ariaid-title24}

Returns the day of the week stored by the GlideDateTime object, expressed in the UTC time zone.
{#r_ScopedGlideDateTimeGetDayOfWeekUTC__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 42. Parameters]

{#r_ScopedGlideDateTimeGetDayOfWeekUTC__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDayOfWeekUTC__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | Day of week value from 1 to 7. Monday equals 1, Sunday equals 7. |
[Table 43. Returns]

{#r_ScopedGlideDateTimeGetDayOfWeekUTC__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-01 12:00:00"); //Thursday
    gs.info(gdt.getDayOfWeekUTC());

Output:

    4

## Scoped GlideDateTime - getDaysInMonthLocalTime() {#ariaid-title25}

Gets the number of days in the month stored by the GlideDateTime object, expressed in
the current user's time zone.
{#r_ScopedGlideDateTimeGetDaysInMonthLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 44. Parameters]

{#r_ScopedGlideDateTimeGetDaysInMonthLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDaysInMonthLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The number of days in the current month in the user's time zone. |
[Table 45. Returns]

{#r_ScopedGlideDateTimeGetDaysInMonthLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-02 12:00:00"); //December
    gs.info(gdt.getDaysInMonthLocalTime());

Output:

    30

## Scoped GlideDateTime - getDaysInMonthUTC() {#ariaid-title26}

Gets the number of days in the month stored by the GlideDateTime object, expressed in
the UTC time zone.
{#r_ScopedGlideDateTimeGetDaysInMonthUTC__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 46. Parameters]

{#r_ScopedGlideDateTimeGetDaysInMonthUTC__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDaysInMonthUTC__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The number of days in the month stored by the GlideDateTime object, expressed in the UTC time zone. |
[Table 47. Returns]

{#r_ScopedGlideDateTimeGetDaysInMonthUTC__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-11-02 12:00:00"); //November
    gs.info(gdt.getDaysInMonthUTC());

Output:

    30

## Scoped GlideDateTime - getDisplayValue() {#ariaid-title27}

Gets the date and time value in the current user's display format and time
zone.
{#r_ScopedGlideDateTimeGetDisplayValue__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 48. Parameters]

{#r_ScopedGlideDateTimeGetDisplayValue__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDisplayValue__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| String | Date and time in the user's format and time zone. Keep in mind when designing business rules or script includes that this method may return values in different formats for different users. |
[Table 49. Returns]

{#r_ScopedGlideDateTimeGetDisplayValue__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.getDisplayValue()); //uses current user session time zone (US/Pacific)

Output:

    2011-08-31 01:00:00

## Scoped GlideDateTime - getDisplayValueInternal() {#ariaid-title28}

Gets the display value in the internal format (yyyy-MM-dd HH:mm:ss).
{#r_ScopedGlideDateTimeGetDisplayValueInternal__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 50. Parameters]

{#r_ScopedGlideDateTimeGetDisplayValueInternal__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDisplayValueInternal__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| String | The date and time values for the GlideDateTime object in the current user's time zone and the internal date and time format of `yyyy-MM-dd HH:mm:ss`. |
[Table 51. Returns]

{#r_ScopedGlideDateTimeGetDisplayValueInternal__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00"); 
    gs.info(gdt.getDisplayValueInternal()); //uses current user session time zone (US/Pacific)

Output:

    2011-08-31 01:00:00

## Scoped GlideDateTime - getDisplayValueLang(String style, String language) {#ariaid-title29}

Returns a date and time value in the current users' locale according to a specified
language and date style.
{#r_SGDT-getDisplayValueLang_S_S__id_wvq_jww_dwb__entry__3}

| Name | Type | Description |
|-|-|-|
| style | String | Specifies the date and time format. Valid values: * full: returns the date in the format of \<weekday, month, day, and year\> according to the user's locale (for example, Monday, October 24, 2022). * long: returns the date in the format of \<month, day, and year\> according to the user's locale (for example, October 24, 2022). * medium: similar to long but returns the date with an abbreviated month (for example, Oct 24, 2022). * short: returns the date in the format of MM/DD/YY or DD/MM/YY according to the user's locale (for example, 10/24/2022 or 24/10/2022). If any other value is passed the API will default to use <var class="keyword varname">medium</var>. Accepted values are not case sensitive. |
| language | String | Returns the date according to a specified language value. Accepts language tags that conform with the BCP-47 standard. For example, `fr` for French or `en-UK` for British English. For a full list of accepted values, see [BCP 47 Language Code List](https://appmakers.dev/bcp-47-language-codes-list/). |
[Table 52. Parameters]

{#r_SGDT-getDisplayValueLang_S_S__id_wvq_jww_dwb} {#r_SGDT-getDisplayValueLang_S_S__id_sdf_kww_dwb__entry__2}

| Type | Description |
|-|-|
| String | A string representation of the date in the style specified and in the appropriate format for the locale of the current user. |
[Table 53. Returns]

{#r_SGDT-getDisplayValueLang_S_S__id_sdf_kww_dwb}  
The following example returns the date and time of the user's locale in all language and
date styles.

    var gdt = new GlideDateTime(); // This will fetch the current date


    gs.info('date: ' + gdt.getDisplayValue());

    gs.info('date: ' + gdt.getDisplayValueLang("full", "fr"));
    gs.info('date: ' + gdt.getDisplayValueLang("long", "en-GB"));
    gs.info('date: ' + gdt.getDisplayValueLang("medium", "de"));
    gs.info('date: ' + gdt.getDisplayValueLang("short", "es-MX"));```

Output:

    date: 2023-01-18 06:49:02
    mercredi 18 janvier 2023 06:49:02
    18 January 2023 06:49:02
    18.01.2023 06:49:02
    18/01/23 06:49:02

## Scoped GlideDateTime - getDSTOffset() {#ariaid-title30}

Gets the amount of time that daylight saving time is offset.
{#r_ScopedGlideDateTimeGetDSTOffset__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 54. Parameters]

{#r_ScopedGlideDateTimeGetDSTOffset__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetDSTOffset__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | Amount of time, in milliseconds, that daylight saving is offset. Returns 0 if there is no offset or if the time is not during daylight saving time. |
[Table 55. Returns]

{#r_ScopedGlideDateTimeGetDSTOffset__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-08-31 08:00:00"); 
    gs.info(gdt.getDSTOffset()); //uses current user session time zone (US/Pacific)

Output:

    3600000

## Scoped GlideDateTime - getErrorMsg() {#ariaid-title31}

Gets the current error message.
{#r_ScopedGlideDateTimeGetErrorMsg__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 56. Parameters]

{#r_ScopedGlideDateTimeGetErrorMsg__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetErrorMsg__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Object | The error message. |
[Table 57. Returns]

{#r_ScopedGlideDateTimeGetErrorMsg__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime(); 
    gdt.setDisplayValue("2011-aa-01 00:00:00"); 
    gs.info(gdt.getErrorMsg());

Output:

    Could not parse DateTime: 2011-aa-01 00:00:00

## Scoped GlideDateTime - getInternalFormattedLocalTime() {#ariaid-title32}

Returns the object's time in the local time zone and in the internal
format.
{#r_SGDT-getInternalFormattedLocalTime__table_lvp_5vc_kw__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 58. Parameters]

{#r_SGDT-getInternalFormattedLocalTime__table_lvp_5vc_kw} {#r_SGDT-getInternalFormattedLocalTime__table_mvp_5vc_kw__entry__2}

| Type | Description |
|-|-|
| String | The object's time in the local time zone and the internal format. |
[Table 59. Returns]

{#r_SGDT-getInternalFormattedLocalTime__table_mvp_5vc_kw}  
This example displays the time in the system time format of the user's timezone.

    var gdt = new GlideDateTime('2022-10-08 01:00:00');
    gs.info(gdt.getDisplayValue());
    gs.info(gdt.getInternalFormattedLocalTime());

Output

    2022-10-07 06:00:00 PM
    18:00:00

## Scoped GlideDateTime - getLocalDate() {#ariaid-title33}

Gets the date stored by the GlideDateTime object, expressed in the standard format,
yyyy-MM-dd, and the current user's time zone.
{#r_ScopedGlideDateTimeGetLocalDate__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 60. Parameters]

{#r_ScopedGlideDateTimeGetLocalDate__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetLocalDate__table_qpt_3f5_jq__entry__2}

| Type |   |
|-|-|
| GlideDate | The date in the user's time zone. |
[Table 61. Returns]

{#r_ScopedGlideDateTimeGetLocalDate__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.getLocalDate());

Output:

    2011-08-31

## Scoped GlideDateTime - getLocalTime() {#ariaid-title34}

Returns a GlideTime object that represents the time portion of the GlideDateTime object
in the user's time zone.
{#r_ScopedGlideDateTimeGetLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 62. Parameters]

{#r_ScopedGlideDateTimeGetLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| GlideTime | The time in the user's time zone. |
[Table 63. Returns]

{#r_ScopedGlideDateTimeGetLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-08-31 08:00:00");
    gt = gdt.getLocalTime();
    gs.info("local time is " + gt.getByFormat('hh:mm:ss'));

Output:

    local time is 01:00:00

## Scoped GlideDateTime - getMonthLocalTime() {#ariaid-title35}

Gets the month stored by the GlideDateTime object, expressed in the current user's time
zone.
{#r_ScopedGlideDateTimeGetMonthLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 64. Parameters]

{#r_ScopedGlideDateTimeGetMonthLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetMonthLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The numerical value of the month. |
[Table 65. Returns]

{#r_ScopedGlideDateTimeGetMonthLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-11-02 12:00:00"); //November
    gs.info(gdt.getMonthLocalTime());

Output:

    11

## Scoped GlideDateTime - getMonthUTC() {#ariaid-title36}

Gets the month stored by the GlideDateTime object, expressed in the UTC time zone.
{#r_ScopedGlideDateTimeGetMonthUTC__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 66. Parameters]

{#r_ScopedGlideDateTimeGetMonthUTC__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetMonthUTC__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The numerical value of the month. |
[Table 67. Returns]

{#r_ScopedGlideDateTimeGetMonthUTC__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-11-02 12:00:00"); //November
    gs.info(gdt.getMonthUTC());

Output:

    11

## Scoped GlideDateTime - getNumericValue() {#ariaid-title37}

Gets the number of milliseconds since January 1, 1970, 00:00:00 GMT.
{#r_ScopedGlideDateTimeNumericValue__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 68. Parameters]

{#r_ScopedGlideDateTimeNumericValue__table_vy2_525_jq} {#r_ScopedGlideDateTimeNumericValue__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The number of milliseconds since January 1, 1970, 00:00:00 GMT. |
[Table 69. Returns]

{#r_ScopedGlideDateTimeNumericValue__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.getNumericValue());

Output:

    1314777600000

## Scoped GlideDateTime - getTime() {#ariaid-title38}

Returns a GlideTime object that represents the time portion of the GlideDateTime
object.
{#r_ScopedGlideDateTimeGetTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 70. Parameters]

{#r_ScopedGlideDateTimeGetTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| GlideTime | The Unix duration stamp in system format based on GMT time. |
[Table 71. Returns]

{#r_ScopedGlideDateTimeGetTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-08-31 08:00:00");
    gt = gdt.getTime();
    gs.info(gt.getByFormat('hh:mm:ss'));

Output:

    08:00:00

## Scoped GlideDateTime - getTZOffset() {#ariaid-title39}

Gets the time zone offset in milliseconds.
{#r_ScopedGlideDateTimeGetTZOffset__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 72. Parameters]

{#r_ScopedGlideDateTimeGetTZOffset__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetTZOffset__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The number of milliseconds of time zone offset. |
[Table 73. Returns]

{#r_ScopedGlideDateTimeGetTZOffset__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.getLocalTime(); // PST local time
    gs.info(gdt.getTZOffset());

Output:

    -25200000

## Scoped GlideDateTime - getUserFormattedLocalTime() {#ariaid-title40}

Returns the object's time in the local time zone and in the user's format.
{#r_SGDT-getUserFormattedLocalTime__table_ddv_fvc_kw__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 74. Parameters]

{#r_SGDT-getUserFormattedLocalTime__table_ddv_fvc_kw} {#r_SGDT-getUserFormattedLocalTime__table_edv_fvc_kw__entry__2}

| Type | Description |
|-|-|
| String | The object's time in the local time zone and in the user's format. |
[Table 75. Returns]

{#r_SGDT-getUserFormattedLocalTime__table_edv_fvc_kw}  
This example shows the object's time in the local time zone.

    var gdt = new GlideDateTime('2022-10-08 01:00:00');
    gs.info(gdt.getDisplayValue());
    gs.info(gdt.getUserFormattedLocalTime());

Output:

    2022-10-07 06:00:00 PM
    06:00:00 PM

## Scoped GlideDateTime - getValue() {#ariaid-title41}

Returns the date and time value stored by the GlideDateTime object in the internal format, yyyy-MM-dd HH:mm:ss, in the UTC time zone.
{#r_ScopedGlideDateTimeGetValue__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 76. Parameters]

{#r_ScopedGlideDateTimeGetValue__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetValue__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| String | Date and time in the internal format and system time zone. Format: yyyy-MM-dd HH:mm:ss in the UTC time zone. |
[Table 77. Returns]

{#r_ScopedGlideDateTimeGetValue__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-08-31 08:00:00");
    gs.info(gdt.getValue());

Output:

    2014-08-31 08:00:00

## Scoped GlideDateTime - getWeekOfYearLocalTime() {#ariaid-title42}

Gets the number of the week stored by the GlideDateTime object, expressed in the current user's time zone.
All weeks begin on Sunday. The first week of the year is the week that contains at least one day of the new year. The week beginning Sunday 2015-12-27 is considered the first week of 2016 as that week contains January 1 and
2.
{#r_ScopedGlideDateTimeGetWeekOfYearLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 78. Parameters]

{#r_ScopedGlideDateTimeGetWeekOfYearLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetWeekOfYearLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The number of the current week. The highest week number in a year is either 52 or 53. |
[Table 79. Returns]

{#r_ScopedGlideDateTimeGetWeekOfYearLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-01 12:00:00");//49th week, 1st week in december 
    gs.info(gdt.getWeekOfYearLocalTime());

Output:

    49

## Scoped GlideDateTime - getWeekOfYearUTC() {#ariaid-title43}

Gets the number of the week stored by the GlideDateTime object, expressed in the UTC time zone.
All weeks begin on Sunday. The first week of the year is the week that contains at least one day of the new year. The week beginning Sunday 2015-12-27 is considered the first week of 2016 as that week contains January 1 and
2.
{#r_ScopedGlideDateTimeGetWeekOfYearUTC__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 80. Parameters]

{#r_ScopedGlideDateTimeGetWeekOfYearUTC__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetWeekOfYearUTC__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | The number of the current week in UTC time. The highest week number in a year is either 52 or 53. |
[Table 81. Returns]

{#r_ScopedGlideDateTimeGetWeekOfYearUTC__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-01 12:00:00");//49th week, 1st week in December 
    gs.info(gdt.getWeekOfYearUTC());

Output:

    49

## Scoped GlideDateTime - getYearLocalTime() {#ariaid-title44}

Gets the year stored by the GlideDateTime object, expressed in the current user's time
zone.
{#r_ScopedGlideDateTimeGetYearLocalTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 82. Parameters]

{#r_ScopedGlideDateTimeGetYearLocalTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetYearLocalTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | Four-digit year value in the user's time zone. |
[Table 83. Returns]

{#r_ScopedGlideDateTimeGetYearLocalTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-11-02 12:00:00");
    gs.info(gdt.getYearLocalTime());

Output:

    2011

## Scoped GlideDateTime - getYearUTC() {#ariaid-title45}

Gets the year stored by the GlideDateTime object, expressed in the UTC time zone.
{#r_ScopedGlideDateTimeGetYearUTC__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 84. Parameters]

{#r_ScopedGlideDateTimeGetYearUTC__table_vy2_525_jq} {#r_ScopedGlideDateTimeGetYearUTC__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Number | 4-digit year value in the UTC time zone. |
[Table 85. Returns]

{#r_ScopedGlideDateTimeGetYearUTC__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-11-02 12:00:00"); 
    gs.info(gdt.getYearUTC());

Output:

    2011

## Scoped GlideDateTime - hasDate() {#ariaid-title46}

Determines if an object's date is set.
{#r_ScopedGlideDateTimeHasDate__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 86. Parameters]

{#r_ScopedGlideDateTimeHasDate__table_vy2_525_jq} {#r_ScopedGlideDateTimeHasDate__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the object date is set; otherwise, returns false. |
[Table 87. Returns]

{#r_ScopedGlideDateTimeHasDate__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.hasDate());

Output:

    true

## Scoped GlideDateTime - isDST() {#ariaid-title47}

Determines if an object's time uses a daylight saving offset.
{#r_ScopedGlideDateTimeIsDST__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 88. Parameters]

{#r_ScopedGlideDateTimeIsDST__table_vy2_525_jq} {#r_ScopedGlideDateTimeIsDST__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the time is daylight saving; otherwise, returns false. |
[Table 89. Returns]

{#r_ScopedGlideDateTimeIsDST__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-08-31 00:00:00");
    gs.info(gdt.isDST()); //true

Output:

    var gdt = new GlideDateTime("2014-08-31 00:00:00");
    gs.info(gdt.isDST()); //true

## Scoped GlideDateTime - isValid() {#ariaid-title48}

Determines if a value is a valid date and time.
{#r_ScopedGlideDateTimeIsValid__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 90. Parameters]

{#r_ScopedGlideDateTimeIsValid__table_vy2_525_jq} {#r_ScopedGlideDateTimeIsValid__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| Boolean | True if value is valid; otherwise, returns false. |
[Table 91. Returns]

{#r_ScopedGlideDateTimeIsValid__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-aa-31 aa:00:00"); 
    gs.info(gdt.isValid()); //true
    gs.info(gdt.getErrorMsg()); //reason

Output:

    false
    Invalid date time: '2011-aa-31 aa:00:00', ignored

## Scoped GlideDateTime - onOrAfter(GlideDateTime gdt) {#ariaid-title49}

Determines if the GlideDateTime object's data and time occurs on or after the specified
GlideDateTime object's date and time.
{#r_SGDT-onOrAfter_GDT__table_sst_nsq_yv__entry__3}

| Name | Type | Description |
|-|-|-|
| gdt | GlideDateTime | Date and time to check against. |
[Table 92. Parameters]

{#r_SGDT-onOrAfter_GDT__table_sst_nsq_yv} {#r_SGDT-onOrAfter_GDT__table_tst_nsq_yv__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the GlideDateTime object's date and time is on or after the date and time specified by the parameter. Possible values: * true: GlideDateTime object date and time is on or after the specified object's date and time. * false: GlideDateTime object date and time is before the specified object's date and time. {#r_SGDT-onOrAfter_GDT__ul_xcn_m2j_zpb} |
[Table 93. Returns]

{#r_SGDT-onOrAfter_GDT__table_tst_nsq_yv}  

    var gdt1 = new GlideDateTime("2016-05-09 10:11:12");
    var gdt2 = new GlideDateTime("2017-06-12 15:11:12");
    gs.info(gdt1.onOrAfter(gdt2));   

Output

    false

## Scoped GlideDateTime - onOrBefore(GlideDateTime gdt) {#ariaid-title50}

Determines if the GlideDateTime object's data and time occurs on or before the
specified GlideDateTime object's date and time.
{#r_SGDT-onOrBefore_GDT__table_srp_2tq_yv__entry__3}

| Name | Type | Description |
|-|-|-|
| gdt | GlideDateTime | Date and time to check against. |
[Table 94. Parameters]

{#r_SGDT-onOrBefore_GDT__table_srp_2tq_yv} {#r_SGDT-onOrBefore_GDT__table_trp_2tq_yv__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the GlideDateTime object's date and time is on or before the date and time specified by the parameter. Possible values: * true: GlideDateTime object date and time is on or before the specified object's date and time. * false: GlideDateTime object date and time is after the specified object's date and time. {#r_SGDT-onOrBefore_GDT__ul_xcn_m2j_zpb} |
[Table 95. Returns]

{#r_SGDT-onOrBefore_GDT__table_trp_2tq_yv}  

    var gdt1 = new GlideDateTime("2016-05-09 10:11:12");
    var gdt2 = new GlideDateTime("2017-06-12 15:11:12");
    gs.info(gdt1.onOrBefore(gdt2));   

Output

    true

## Scoped GlideDateTime - setDayOfMonthLocalTime(Number day) {#ariaid-title51}

Sets the day of the month to a specified value in the current user's time
zone.
{#r_ScopedGlideDateTimeSetDayOfMonthLocalTime_Number_day__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| day | Number | The day of month to change to, from 1 to 31. If this value is greater than the maximum number of days in the month, the value is set to the last day of the month. |
[Table 96. Parameters]

{#r_ScopedGlideDateTimeSetDayOfMonthLocalTime_Number_day__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetDayOfMonthLocalTime_Number_day__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 97. Returns]

{#r_ScopedGlideDateTimeSetDayOfMonthLocalTime_Number_day__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.setDayOfMonthLocalTime(9);
    gs.info(gdt.getDayOfMonthLocalTime());

Output:

    9

## Scoped GlideDateTime - setDayOfMonthUTC(Number day) {#ariaid-title52}

Sets the day of the month to a specified value in the UTC time zone.
{#r_ScopedGlideDateTimeSetDayOfMonthUTC_Number_day__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| day | Number | The day of month to change to, from 1 to 31. If this value is greater than the maximum number of days in the month, the value is set to the last day of the month. |
[Table 98. Parameters]

{#r_ScopedGlideDateTimeSetDayOfMonthUTC_Number_day__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetDayOfMonthUTC_Number_day__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 99. Returns]

{#r_ScopedGlideDateTimeSetDayOfMonthUTC_Number_day__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.setDayOfMonthUTC(9);
    gs.info(gdt.getDayOfMonthUTC());

Output:

    9

## Scoped GlideDateTime - setDisplayValue(String asDisplayed) {#ariaid-title53}

Sets a date and time value using the current user's display format and time
zone.
{#r_ScopedGlideDateTimeSetDisplayValue_String_asDisplayed__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| asDisplayed | String | The date and time in the current user's display format and time zone. The parameter must be formatted using the current user's preferred display format, such as MM-dd-yyyy HH:mm:ss. To assign the current date and time to a variable in a workflow script, use <var class="keyword varname">variable</var> `.setDisplayValue(gs.nowDateTime);`. |
[Table 100. Parameters]

{#r_ScopedGlideDateTimeSetDisplayValue_String_asDisplayed__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetDisplayValue_String_asDisplayed__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 101. Returns]

{#r_ScopedGlideDateTimeSetDisplayValue_String_asDisplayed__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-02-02 12:00:00");
    gdt.setDisplayValue("2014-01-01 12:00:00");//uses current user session time zone (US/Pacific) 
    gs.info(gdt.getValue());

Output:

    2014-01-01 20:00:00

## Scoped GlideDateTime - setDisplayValue(String value, String format) {#ariaid-title54}

Sets a date and time value using the current user's time zone and the specified date
and time format.
This method throws a runtime exception if the date and time format used in the
value parameter does not match the format
parameter. You can retrieve the error message by calling getErrorMsg() on
the GlideDateTime object after the exception is caught.
{#r_ScopedGlideDateTimeSetDisplayValue_String_value_String_format__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| value | String | Date and time in the current user's time zone. |
| format | String | Date and time format to use to parse the value parameter. Use the following values to describe the value parameter: * dd: Day of the month * MM: Month of the year * yyyy: Year * HH: Hour * mm: Minutes * ss: Seconds {#r_ScopedGlideDateTimeSetDisplayValue_String_value_String_format__ul_h13_nvr_ckb} For example: "dd-MM-yyyy HH:mm:ss" or "MM-dd-yyyy HH:mm". |
[Table 102. Parameters]

{#r_ScopedGlideDateTimeSetDisplayValue_String_value_String_format__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetDisplayValue_String_value_String_format__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 103. Returns]

{#r_ScopedGlideDateTimeSetDisplayValue_String_value_String_format__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-02-02 12:00:00");
    gdt.setDisplayValue("20-5-2011 12:00:00", "dd-MM-yyyy HH:mm:ss"); //uses current user session time zone
    gs.info(gdt.getValue());

Output

    "20-05-2011 12:00:00"

## Scoped GlideDateTime - setDisplayValueInternal(String value) {#ariaid-title55}

Sets a date and time value using the internal format (yyyy-MM-dd HH:mm:ss) and the
current user's time zone.
{#r_ScopedGlideDateTimeSetDisplayValueInternal_String_value__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| value | String | The date and time in internal format. |
[Table 104. Parameters]

{#r_ScopedGlideDateTimeSetDisplayValueInternal_String_value__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetDisplayValueInternal_String_value__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 105. Returns]

{#r_ScopedGlideDateTimeSetDisplayValueInternal_String_value__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2014-02-02 12:00:00");
    gdt.setDisplayValueInternal("2014-01-01 12:00:00"); //uses current user session time zone (US/Pacific)
    gs.info(gdt.getValue());

Output:

    2014-01-01 20:00:00

## Scoped GlideDateTime - setDisplayValueLang(String dateTime, String style) {#ariaid-title56}

Sets a date and time using a specified style and format according to the current user's
locale.
{#r_SGDT-setDisplayValueLang_S_S__id_wc2_nww_dwb__entry__3}

| Name | Type | Description |
|-|-|-|
| dateTime | String | Date and time value for the GlideDate object in the current user's time zone. Valid values are any date and time output from the getDisplayValueLang() function. For instance, using output from the getDisplayValueLang(String style, String language) example earlier in this topic, November 28, 2022 07:03:41 or 28.11.2022 07:03:41 are accepted values. |
| style | String | Specifies the date format. Valid values: * full: returns the date in the format of \<weekday, month, day, and year\> according to the user's locale (for example, Monday, October 24, 2022). * long: returns the date in the format of \<month, day, and year\> according to the user's locale (for example, October 24, 2022). * medium: similar to long but returns the date with an abbreviated month (for example, Oct 24, 2022). * short: returns the date in the format of MM/DD/YY or DD/MM/YY according to the user's locale (for example, 10/24/2022 or 24/10/2022). If any other value is passed the API will default to use <var class="keyword varname">medium</var>. Accepted values are not case sensitive. |
[Table 106. Parameters]

{#r_SGDT-setDisplayValueLang_S_S__id_wc2_nww_dwb} {#r_SGDT-setDisplayValueLang_S_S__id_srr_nww_dwb__entry__2}

| Type | Description |
|-|-|
| Void |   |
[Table 107. Returns]

{#r_SGDT-setDisplayValueLang_S_S__id_srr_nww_dwb}  
The following example returns the date and time in short and full styles.

    var glideDateFR = new GlideDateTime();
    glideDateFR.setDisplayValueLang("2/3/2023 17:27:56", "short");

    gs.info('date: ' + glideDateFR.getDisplayValue());
    gs.info('date: ' + glideDateFR.getDisplayValueLang("full"));

Output:

    date: 2023-02-03 17:27:56
    date: Friday, February 3, 2023 17:27:56

## Scoped GlideDateTime - setDisplayValueLang(String dateTime, String style, String
language) {#ariaid-title57}

Sets a date and time using a specified style, language, and format according to the
current user's locale.
{#r_SGDT-setDisplayValueLang_S_S_S__id_sgm_qww_dwb__entry__3}

| Name | Type | Description |
|-|-|-|
| dateTime | String | Date and time value for the GlideDate object in the current user's time zone. Valid values are any date and time output from the getDisplayValueLang() function. For instance, using output from the getDisplayValueLang(String style, String language) example earlier in this topic, November 28, 2022 07:03:41 or 28.11.2022 07:03:41 are accepted values. |
| style | String | Specifies the date format. Valid values: * full: returns the date in the format of \<weekday, month, day, and year\> according to the user's locale (for example, Monday, October 24, 2022). * long: returns the date in the format of \<month, day, and year\> according to the user's locale (for example, October 24, 2022). * medium: similar to long but returns the date with an abbreviated month (for example, Oct 24, 2022). * short: returns the date in the format of MM/DD/YY or DD/MM/YY according to the user's locale (for example, 10/24/2022 or 24/10/2022). If any other value is passed the API will default to use <var class="keyword varname">medium</var>. Accepted values are not case sensitive. |
| language | String | Sets the language using a language tag that conforms with the BCP-47 standard. For example, `fr` for French or `en-UK` for British English. For a full list of accepted values, see [BCP 47 Language Code List](https://appmakers.dev/bcp-47-language-codes-list/). |
[Table 108. Parameters]

{#r_SGDT-setDisplayValueLang_S_S_S__id_sgm_qww_dwb} {#r_SGDT-setDisplayValueLang_S_S_S__id_nst_qww_dwb__entry__2}

| Type | Description |
|-|-|
| Void |   |
[Table 109. Returns]

{#r_SGDT-setDisplayValueLang_S_S_S__id_nst_qww_dwb}  
The following example returns the date and time in short and full styles for English and
French.

    var glideDateFR = new GlideDateTime(); 

    glideDateUS.setDisplayValueLang("2/3/2023 18:00:00", "short", "en-US" );
    glideDateFR.setDisplayValueLang("2/3/2023 18:00:00", "short", "fr-FR" );

    gs.info('en-US date: ' + glideDateUS.getDisplayValue());
    gs.info('en-US date: ' + glideDateUS.getDisplayValueLang("full"));

    gs.info('fr-FR date: ' + glideDateFR.getDisplayValue());
    gs.info('fr-FR date: ' + glideDateFR.getDisplayValueLang("full"));

Output:

    en-US date: 2023-02-03 18:00:00
    en-US date: Friday, February 3, 2023 18:00:00
    fr-FR date: 2023-03-02 18:00:00
    fr-FR date: Thursday, March 2, 2023 18:00:00

## Scoped GlideDateTime - setGlideDateTime(GlideDateTime g) {#ariaid-title58}

Sets the date and time of the current object using an existing GlideDateTime object.
This method is equivalent to instantiating a new object with a GlideDateTime
parameter.
{#r_ScopedGlideDateTimeSetGlideDateTime_g__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| g | GlideDateTime | The object to use for setting the datetime value. |
[Table 110. Parameters]

{#r_ScopedGlideDateTimeSetGlideDateTime_g__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetGlideDateTime_g__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 111. Returns]

{#r_ScopedGlideDateTimeSetGlideDateTime_g__table_qpt_3f5_jq}  

    var dt1 = new GlideDateTime("2011-01-01 12:00:00");
    var dt2 = new GlideDateTime("2011-02-02 08:00:00");
    dt1.setGlideDateTime(dt2);
    gs.info(dt1.getValue());

Output:

    2011-02-02 08:00:00

## Scoped GlideDateTime - setMonthLocalTime(Number month) {#ariaid-title59}

Sets the month stored by the GlideDateTime object to the specified value using the
current user's time zone.
{#r_ScopedGlideDateTimeSetMonthLocalTime_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| month | Number | The month to change to. |
[Table 112. Parameters]

{#r_ScopedGlideDateTimeSetMonthLocalTime_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetMonthLocalTime_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 113. Returns]

{#r_ScopedGlideDateTimeSetMonthLocalTime_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.setMonthLocalTime(1);
    gs.info(gdt.getMonthLocalTime());

Output:

    1

## Scoped GlideDateTime - setMonthUTC(Number month) {#ariaid-title60}

Sets the month stored by the GlideDateTime object to the specified value using the UTC
time zone.
{#r_ScopedGlideDateTimeSetMonthUTC_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| month | Number | The month to change to. |
[Table 114. Parameters]

{#r_ScopedGlideDateTimeSetMonthUTC_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetMonthUTC_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 115. Returns]

{#r_ScopedGlideDateTimeSetMonthUTC_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.setMonthUTC(1);
    gs.info(gdt.getMonthUTC());

Output:

    1

## Scoped GlideDateTime - setValue(String o) {#ariaid-title61}

Sets the date and time of the GlideDateTime object.
{#r_ScopedGlideDateTimeSetValue_String_o__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| o | String | The date and time to use. This parameter may be one of several types: * A string in the UTC time zone and the internal format of yyyy-MM-dd HH:mm:ss. Sets the value of the object to the specified date and time. Using the method this way is equivalent to instantiating a new GlideDateTime object using the GlideDateTime(String value) constructor. If the date and time format used does not match the internal format, the method attempts to set the date and time using other available formats. Resolving the date and time this way can lead to inaccurate data due to ambiguity in the day and month values. When using a non-standard date and time format, use setValueUTC(String dt, String format) instead. * A GlideDateTime object. Sets the value of the object to the date and time stored by the GlideDateTime passed in the parameter. Using the method this way is equivalent to instantiating a new GlideDateTime object using the GlideDateTime(GlideDateTime g) constructor. * A JavaScript Number. Sets the value of the object using the Number value as milliseconds past January 1, 1970 00:00:00 UTC. {#r_ScopedGlideDateTimeSetValue_String_o__ul_jp2_mhc_fr} |
[Table 116. Parameters]

{#r_ScopedGlideDateTimeSetValue_String_o__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetValue_String_o__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 117. Returns]

{#r_ScopedGlideDateTimeSetValue_String_o__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-01-01 12:00:00");
    gdt.setValue("2011-02-02 08:00:00");  // value set =  2011-02-02 08:00:00
    gs.info(gdt.getValue());

Output:

    2011-02-02 08:00:00

## Scoped GlideDateTime - setValueUTC(String dt, String format) {#ariaid-title62}

Sets a date and time value using the UTC time zone and the specified date and time
format. This method throws a runtime exception if the date and time format used in the
dt parameter does not match the format parameter.
You can retrieve the error message by calling `getErrorMsg()` on the
GlideDateTime object after the exception is caught.
{#r_ScopedGlideDateTimeSetValueUTC_String_dt_String_format__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| dt | String | The date and time to use. |
| format | String | The date and time format to use. |
[Table 118. Parameters]

{#r_ScopedGlideDateTimeSetValueUTC_String_dt_String_format__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetValueUTC_String_dt_String_format__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 119. Returns]

{#r_ScopedGlideDateTimeSetValueUTC_String_dt_String_format__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-01-01 12:00:00");
    gdt.setValueUTC("15-02-2011 08:00:00", "dd-MM-yyyy HH:mm:ss");
    gs.info(gdt.getValue());

Output:

    2011-02-15 08:00:00

## Scoped GlideDateTime - setYearLocalTime(Number year) {#ariaid-title63}

Sets the year stored by the GlideDateTime object to the specified value using the
current user's time zone.
{#r_ScopedGlideDateTimeSetYearLocalTime_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| year | Number | The year to change to. |
[Table 120. Parameters]

{#r_ScopedGlideDateTimeSetYearLocalTime_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetYearLocalTime_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 121. Returns]

{#r_ScopedGlideDateTimeSetYearLocalTime_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.setYearLocalTime(2013);
    gs.info(gdt.getYearLocalTime());

Output:

    2013

## Scoped GlideDateTime - setYearUTC(Number year) {#ariaid-title64}

Sets the year stored by the GlideDateTime object to the specified value using the UTC
time zone.
{#r_ScopedGlideDateTimeSetYearUTC_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| year | Number | The year to change to. |
[Table 122. Parameters]

{#r_ScopedGlideDateTimeSetYearUTC_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeSetYearUTC_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 123. Returns]

{#r_ScopedGlideDateTimeSetYearUTC_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime();
    gdt.setYearUTC(2013);
    gs.info(gdt.getYearUTC());

Output:

    2013

## Scoped GlideDateTime - subtract(GlideTime time) {#ariaid-title65}

Subtracts a specified amount of time from the current GlideDateTime object.
{#r_ScopedGlideDateTimeSubtract_GlideTime__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| time | GlideTime | The time value to subtract. |
[Table 124. Parameters]

{#r_ScopedGlideDateTimeSubtract_GlideTime__table_vy2_525_jq} {#r_ScopedGlideDateTimeSubtract_GlideTime__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 125. Returns]

{#r_ScopedGlideDateTimeSubtract_GlideTime__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    var gtime1 = new GlideTime();
    gtime1.setValue("00:00:20");
    gdt.subtract(gtime1);
    var gtime2 = gdt.getTime();
    gs.info(gtime2.getByFormat('hh:mm:ss'));

Output:

    07:59:40

## Scoped GlideDateTime - subtract(Number milliseconds) {#ariaid-title66}

Subtracts the specified number of milliseconds from the GlideDateTime object.
{#r_ScopedGlideDateTimeSubtract_Number__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| milliseconds | Number | Number of milliseconds to subtract. |
[Table 126. Parameters]

{#r_ScopedGlideDateTimeSubtract_Number__table_vy2_525_jq} {#r_ScopedGlideDateTimeSubtract_Number__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 127. Returns]

{#r_ScopedGlideDateTimeSubtract_Number__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-12-07 08:00:00");
    gdt.subtract(1000);
    gs.info(gdt.getValue());

Output:

    2011-12-07 07:59:59

## Scoped GlideDateTime - subtract(GlideDateTime start, GlideDateTime end) {#ariaid-title67}

Returns the duration difference between two specified GlideDateTime
objects.
{#r_ScopedGlideDateTimeSubtract_GlideDateTime_GlideDate_Time__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| Start | GlideDateTime | Start date object. |
| End | GlideDateTime | End date object. |
[Table 128. Parameters]

{#r_ScopedGlideDateTimeSubtract_GlideDateTime_GlideDate_Time__table_vy2_525_jq} {#r_ScopedGlideDateTimeSubtract_GlideDateTime_GlideDate_Time__table_qpt_3f5_jq__entry__2}

| Type | Description |
|-|-|
| GlideDuration | Duration difference between the two specified dates. |
[Table 129. Returns]

{#r_ScopedGlideDateTimeSubtract_GlideDateTime_GlideDate_Time__table_qpt_3f5_jq}  

    var gdt1 = new GlideDateTime("2011-08-28 09:00:00");
    var gdt2 = new GlideDateTime("2011-08-31 08:00:00");
     
    var dur = GlideDateTime.subtract(gdt1, gdt2); //the difference between gdt1 and gdt2
    gs.info(dur.getDisplayValue());

Output:

    2 Days 23 Hours

## Scoped GlideDateTime - toString() {#ariaid-title68}

Gets the date and time value stored by the GlideDateTime object in the internal format, yyyy-MM-dd HH:mm:ss, and the system time zone, UTC by default. This method is equivalent to getValue().
{#r_ScopedGlideDateTimeToString__table_vy2_525_jq__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 130. Parameters]

{#r_ScopedGlideDateTimeToString__table_vy2_525_jq} {#r_ScopedGlideDateTimeToString__table_qpt_3f5_jq__entry__2}

| Type |   |
|-|-|
| String | The date and time stored by the GlideDateTime object in the system time zone and format. |
[Table 131. Returns]

{#r_ScopedGlideDateTimeToString__table_qpt_3f5_jq}  

    var gdt = new GlideDateTime("2011-08-31 08:00:00");
    gs.info(gdt.toString());

Output:

    2011-08-31 08:00:00


