To get time from glide date time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 05:24 AM
I am not getting the time field from the below code as i have to set it to 08:00:00 how should i do it. next day date i am getting properly how to get the time.And then return the complete date and set the field in client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 06:17 AM
Hi Joshi,
Use below code for time..
var gg = new GlideDateTime();
gs.print('gg'+gg);
var str = gg.toString();
var dateSplt = str.split(' ');
var time = dateSplt[1];
gs.print('hello'+ time);
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response is useful.
Regards,
Sadasiva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 06:20 AM
In the above code...
var dateArr = str.split('(here it is space) ');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 06:23 AM
yup its working the date format for the planned start date fields are in dd:mm:year format after the script is running its converting into yy:mm:dd what should be done to keep it in current format .where should i make changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 06:30 AM
Hi Bhagyashree, there's a GlideTime function getByFormat you can use:
var gg = new GlideDateTime();
gg.addDays(1);
var date = gg.getDate();
var time = gg.getTime();
gs.addInfoMessage(date);
gs.addInfoMessage(time.getByFormat('HH:mm:ss'));
gs.addInfoMessage(gg);
A couple of notes:
- The documentation suggests not using addDays; use addDaysLocalTime or addDaysUTC instead. This will account for Time Zone changes and oddities.
- This shows the time in the default system time zone, probably UTC. If you want it to show your local time, use getLocalTime() instead of getTime().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 03:38 PM
I need help with something, I have a field that is a string where a enter numbers for a time to completion of a Knowledge Article. I need to change that field to a GlideDuration field, so I need to convert all the Knowledge Articles that has the time in a string to a glideDuration how can I do that with a script?
Thanks in advance.