How can I add a day to GlideDateTime object in scoped app?

Joseph Gabriel
Tera Contributor

In global scope, I could something like the following:

    new GlideDateTime().addDaysLocalTime(1)

However, this doesn't work in a scoped app.   And, as far as I can tell, GlideDateTime makes it very difficult to set an accurate date/time value from a standard JS date.

So....what are my options?   Thanks!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi Joseph,



Following script runs properly in scoped app:


I ran this in background script in scoped app and it ran fine




var gdt = new GlideDateTime("2011-08-31 08:00:00");


gdt.addDaysLocalTime(-1);


gs.info(gdt.getLocalDate());



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

Hi Joseph,



Following script runs properly in scoped app:


I ran this in background script in scoped app and it ran fine




var gdt = new GlideDateTime("2011-08-31 08:00:00");


gdt.addDaysLocalTime(-1);


gs.info(gdt.getLocalDate());



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Be careful here, despite the scope you think you are in background scripts always run in Global