---
sourceDocument: Referência da API de Yokohama
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/yokohama/api-reference

 Release :

    - yokohama

ft:locale :

    - pt-BR

ft:publication_title :

    - Referência da API de Yokohama

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Modifique um valor do campo GlideDateTime

# Modifique um valor do campo GlideDateTime {#ariaid-title1}

* Versão de lançamento: Yokohama
* 
* Atualizado 30 de jan. de 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 min. de leitura

Este exemplo demonstra como modificar um GlideDateTime valor do campo usando um script do lado do servidor.
Dado um GlideDateTime objeto de script ou campo, mostre uma variedade de maneiras de modificar o valor facilmente. O mesmo conceito também se aplica ao GlideDate objeto.  
Nota:  
O script a seguir destina-se apenas a aplicações globais.

    //You first need a GlideDateTime object
    //this can be from instantiating a new object "var gdt = new GlideDateTime()"
    //or getting the object from a GlideDateTime field
    //getting the field value (for example: var gdt = current.start_date) only returns the string value, not the object
    //to get the object use var gdt = current.start_date.getGlideObject();
    //now gdt is a GlideDateTime object
    var gdt = current.start_date.getGlideObject();
     
    //All methods can use negative values to subtract intervals
     
    //add 1 hour (60 mins * 60 secs)
    gdt.addSeconds(3600);
     
    //add 1 day
    gdt.addDaysLocalTime(1);
     
    //subtract 1 day
    gdt.addDaysLocalTime(-1);
     
    //add 3 weeks
    gdt.addWeeksLocalTime(3);
     
    //subtract 6 months
    gdt.addMonthsLocalTime(-6);
     
    //add 1 year, representing the date and time using the UTC timezone instead of the local user's timezone.
    gdt.addYearsUTC(1);
     
    //set the value of the GlideDateTime object to the current session timezone/format
    GlideSession.get().setTimeZoneName('US/Eastern');
    gdt.setDisplayValue('2018-2-28 00:00:00');
    gs.info('In ' + GlideSession.get().getTimeZoneName() + ": " + gdt.getDisplayValue());


