- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 08:55 PM
I want to convert string date (2019-MAR-22) to date format (03-22-2019).
Regards,
Rushi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 09:13 PM
Hi Rushi,
Try the below script:
Script:
var date = '2019-MAR-22';//Input Date
var gd = new GlideDate();
gd.setDisplayValue(date, "yyyy-MMM-dd");
gs.print('output '+gd.getByFormat("MM/dd/yyyy"));//Output
Output of the srcript would be :
Please mark helpful and correct.
Thanks,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 09:39 PM
Hi Rushi,
In addition
Mark helpful or correct based on impact.
Regards,
Priyanka A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 09:59 PM
Hi Rushi,
Please find the below working code as per your requirement.
var date = '2019-MAR-22'; // your input date
var simpleDateFormat = 'yyy-MMM-dd'; // Simple Date Time format
var gdt = new GlideDateTime();
gdt.setDisplayValue(date,simpleDateFormat);
var localedt =gdt.getLocalDate();
var getStart= localedt.getByFormat('MM-dd-yyyy'); //this is your out put date format
gs.addInfoMessage(getStart);
output:
input from user: 2019-MAR-22
output:03-22-2019
Hope this is helpful and please mark if you find the appropriate solution.
Regards,
Imam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:23 AM
Hi,
var dateTime = '10 Jul 2018 12:30:10';
var dateFormat = 'dd MMMM yyyy HH:mm:ss';
var gDate= new GlideDateTime();
gdt.setDisplayValue(dateTime,dateFormat );
gs.print(gDate.getDisplayValue());
i tried above code in background script and it is working correctly.
so try above code .
Mark this answer as correct if it helped.
Thanks,
Manjusha Bangale