Please help with formatting date and time in notification on sc_req_item table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 02:51 PM
Hello everyone,
We have been trying to formatting date and time variable on the sc_req_item table, but we are having a difficult time getting it to work. We are on Tokyo version. Please help. Thank you
format from "Purchased Date: 12-15-2023 02:24:04 PM PST"
to "Purchased Date: Friday, December 15. 2023 02:24 PM
Currently Notification:
Currently Output:
Description: Test
Purchased Date: 12-30-2023 02:24:04 PM PST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 03:07 PM - edited 12-15-2023 03:39 PM
Hi @Radhika11,
Please share the formatting part from mail script.
You have to get Day, Month and Day from date object and them print together.
Try the below code in backgroup script and adjust the same in mail script
var gDate = new GlideDateTime().getDate();
var newDate = gDate.getByFormat('EEEE, MMMM dd HH:mm:ss a z');
//gs.print(gDate.getByFormat('EEEE, MMMM dd HH:mm:ss a z'));
gs.print(newDate);
The output of this code
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 03:33 PM
Hello @Radhika11
here is the javascript that generates date time in the format you need.
var gd = new GlideDate();
gd.setValue('2021-04-21 22:12:55');
gs.log(gd.getByFormat("EEEE, LLLL dd, yyyy hh:mm a"));
// output: Wednesday, April 21, 2021 10:12 PM
Please see the following SN and JAVA APIs for more details.
https://docs.oracle.com/javase/10/docs/api/java/text/SimpleDateFormat.html
hope this helped
--
Bala Guthy
Please mark this as helpful or a solution as appropriate.