How would I fix this date/time issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 05:55 PM
Our instance date/time is below:
I am trying to set Start Travel Time to the same value as Mobile Travel Start but you can see it's doing some level of conversion. How do I make it keep the original?
Note - Mobile Travel Start is a text field and Start Travel Time is a date/time field. From my mobile app there's an issue with date/times so I'm not actually able to map my date/time field to Start Travel Time directly (it just stores an empty field). My work around was to store the data in a text field first so I could manipulate it and add it back.
I have tried
They both have the same result where it looks like it's setting it to 3pm even though I selected 7pm central time on my phone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 02:16 AM - edited 05-11-2023 02:19 AM
Dear @e_wilber
Please try using the below code,
Option 1 :
var travelStart = new GlideDateTime(current.u_mobile_travel_start);
gs.info('date: ' + travelStart.getDisplayValue());
GlideSession.get().setTimeZoneName('US/Eastern');
gs.info('In ' + GlideSession.get().getTimeZoneName() + ": " + gdt.getDisplayValue());
- Kailas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 04:07 AM
Hi @e_wilber ,
If you want to display the date as it is which you are storing in the Mobile Travel start field (String type) then you can just use setDisplayValue to set value for Start Travel Time field. Please refer below code:
<field name>.setDisplayValue(<date string want to set for this field>);
start_travel_time .setDisplayValue("2023-05-10 19:32:00");
Please ask if you face any problem.
If I am able to help you with your question, Please click the Thumb Icon and mark as Correct.
Regards,
Pushkar