Hi All,
I've been playing around with the code task in an action as I'd like to format the ticket metadata Field/updatedAt date and time to a more friendly time and provide this in an email.
For example: ${tck://Field/updatedAt} will return 2021-04-01T09:07:02.362Z
Using the below code I can get half way there. I need to sort out the date so that it's a British format and also the time so that it takes into account the daylight saving time. When you take a look at the time in the follow-up screen in Qualtrics you can see that it's an hour out.
function codeTask() {
var d = new Date('${tck://Field/updatedAt}');
var n = d.toLocaleDateString() + ' ' + d.toLocaleTimeString();
return {
result : n
}
}
Using the above example, this returns '2021-4-01 09:07:02'.
These are my settings in my account:
How in code do I offset the time by the appropriate daylight saving time and how do I tell JavaScript I wish to see the British Date format?
Hope you can help
Thanks
Rod Pestell
CodeTask adjust Ticket updatedAt time to reflect Daylight Saving Time
HI All, just wondering if anyone can advise please on this?
Thanks
Rod Pestell
Hi All,
I came across some code here: https://stackoverflow.com/questions/34819299/calculating-bst-time-from-date-object which I'm wondering might actually resolve my issue. My plan would be to implement this as a code task so I'm limited to some extent as I think i wouldn't be able to reference an external library like moment.js.
Would welcome your thoughts.
Thanks
Rod Pestell
Leave a Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.