- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2020 11:16 PM
Hello,
We have 2 fields in a form.
1. Expected Start Date/Time
2. Expected End Date/Time
The above 2 fields show the system date/time.
I want 2 more fields below below the above mentioned fields with name :
1. Expected Start Date/Time (EST)
2. Expected End Date/Time (EST)
Requirement :
Expected Start Date/Time (EST) will be copied from Expected Start Date/Time once the user fill this field and show EST time.
Expected End Date/Time (EST) will be copied from Expected End Date/Time once the user fill this field and show EST time.
Can someone please help in how to achieve this functionality?
NOTE : The fields are in scoped application.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2021 11:57 PM
Okay.
Hi create a SI in global scope and then call that Si from your client script. Then you can use the following code to convert your date/time to EST format.
Script Include
getConvertedDate: function() {
var mydate = new GlideDateTime(this.getParameter('sysparm_date').toString());
var gdt1 = new GlideDateTime();
//sets to EST
var tz = Packages.java.util.TimeZone.getTimeZone("EST");
gdt1.setTZ(tz);
gdt1.setValue(mydate);
return gdt1.getDisplayValue(); //returns the date/time in EST timezone as a string.
},
Mark the comment as a correct answer and also helpful if this helps to solve the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 03:22 AM
Hi,
The syntax is wrong. template.print() takes only 1 arguent. So there shoudl not be comma.
Here is how to show
template.print("Expected start : "+current.your_field.getDisplayValue());
Mark the comment as helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 03:42 AM
Hi Asif,
It is not coming correctly.
The issue is while sending notification, the time is getting converted into GMT again.
In form, user fill 'Expected Start Date/Time' and 'Expected End Date/Time' and our script include and client script converting that Date/Time value in EST and populate the same in 'Expected Start Date/Time (EST)' and 'Expected End Date/Time (EST)' fields.
I want 'Expected Start Date/Time (EST)' and 'Expected End Date/Time (EST)' fields to be printed in notification in EST.
But I am getting wrong values.
Change Form :
Email getting :
Mail Script : print_time_in_EST
Notification :
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:09 AM
Hi,
can you try getValue() instead of getDisplayValue() and check it once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:29 AM
Okay.
In that case, i suggest you call the same SI code in the mail script and check it once.
var mydate = new GlideDateTime(current.your_field);
var gdt1 = new GlideDateTime();
//sets to EST
var tz = Packages.java.util.TimeZone.getTimeZone("EST");
gdt1.setTZ(tz);
gdt1.setValue(mydate);
template.print("Expected Start Date/Time: "+gdt1.getDisplayValue());