How to convert date format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2014 05:45 AM
Hello all,
I have an inbound action which reads content of the email and populates a table with the information from the email body.
My issues is that the email contains long format date e.g. 24th March 2014 at 23:59hrs and I need to convert this to short format dd/mm/yyyy so it can populate date field on the form.
Appreciate any help with this.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2014 03:42 AM
if you are doing this through code you could try the following example.
//sample date string
var sampleDate = "Sat Jun 09 2007 17:46:21";
//function to format the date string
function formattedDate(date) {
var d = new Date(date || Date.now()),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [day, month, year].join('/');
}
//call it like so formattedDate(now)
document.write(formattedDate(now));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2014 04:36 AM
Terry,
Thank you for your help.
Is there different way to do this then code?
Shoaib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2014 05:38 AM
Sorry im new to service-now. Maybe someone else has an easier way to fix the issue ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2014 06:59 AM
Can i ask how the date is created? Is this by the end user - so do they input the date in the email or is this a time stamp with no room for human error?
Terry Slattery is quite right that you will need to write a function to convert the date into the applicable format.