Need help with date/time field converting to string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2018 05:50 PM
Hi,
I have the below script include, my start date field is date/time field.
With the below script, start date field output is being displayed as: MM - DD TIME - Year
For example: 08-05 00:00:00- 2018
i need the output as: 08-05-2018 00:00:00
var sc_include = function () {
var pencil = new cr_pencil();
return {
biglist: biglist,
type: 'sc_include'
};
function biglist(variables) {
var date = variables.start_date;
if (date) {
date = date.toString();
var day = date.split('-')[2];
var month = date.split('-')[1];
var year = date.split('-')[0];
if (variables.region == 'UK') {
date = [day, month, year].join('-');
} else {
date = [month, day, year].join('-');
}
}
return [{
condition: true,
label: '\n' + 'Start date: ',
value: date
}
]}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 01:04 AM
Hi,
Maybe you can try this:
var date = variables.start_date;
var dt= new GlideDateTime(date);
gs.log(dt);
if (date) {
//date = date.toString();
var day = dt.getDayOfMonth;
var month = dt.getMonth;
var year = dt.getYear();
var str= '';
if (variables.region == 'UK') {
str= [day, month, year].join('-');
} else {
str= [month, day, year].join('-');
}
}
return str;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 10:14 AM
Please mark this thread closed my marking an answer correct if it resolved your issue
Please mark this response as correct or helpful if it assisted you with your question.