Hi Natalie!
The hardest part of this would be getting the abbreviated time zone. It’s currently set up to return only standard time, even when it should be, for example, PDT. The reason the time is failing is because this code doesn’t handle two-digit hours.
This code should work for you. The hard part was getting the abbreviated time zone, as Axure only gives it to you spelled out – E.g., ‘Pacific Standard Time.’ This code takes the first letter from each of the first two words of the spelled-out time zone and adds a T. It’s ugly.
[[Now.addDays(Item.dateOffset1).getMonthName()]] [[Now.addDays(Item.dateOffset1).getDate()]], [[Now.addDays(Item.dateOffset1).getFullYear()]] [[Now.toLocaleTimeString().substring(0,Now.toLocaleTimeString().indexOf(':'))]]:[[Now.getMinutes()]] [[Now.getHours()<12 && 'AM' || 'PM']] [[Now.toTimeString().substr(Now.toTimeString().indexOf('(')+1,1))]][[Now.toTimeString().substr(Now.toTimeString().indexOf(' ', Now.toTimeString().indexOf('('))+1,1)]]T
[Edit] Oops! Hang on: You’ll need a leading 0 for the minutes when it’s just one digit. THIS should work:
[[Now.addDays(Item.dateOffset1).getMonthName()]] [[Now.addDays(Item.dateOffset1).getDate()]], [[Now.addDays(Item.dateOffset1).getFullYear()]] [[Now.toLocaleTimeString().substring(0,Now.toLocaleTimeString().indexOf(':'))]]:[[0.concat(Now.getMinutes()).slice(-2)]] [[Now.getHours()<12 && 'AM' || 'PM']] [[Now.toTimeString().substr(Now.toTimeString().indexOf('(')+1,1))]][[Now.toTimeString().substr(Now.toTimeString().indexOf(' ', Now.toTimeString().indexOf('('))+1,1)]]T
[Edit] Okay, one last bug fix. The one above doesn’t properly adjust time to standard time for a date in, say, January, when offset from the current date. Basically I used the addDays() function everywhere I thought it might make a difference. It’s curious why the hour doesn’t offset when in standard time…
[[Now.addDays(Item.dateOffset1).getMonthName()]] [[Now.addDays(Item.dateOffset1).getDate()]], [[Now.addDays(Item.dateOffset1).getFullYear()]] [[Now.addDays(Item.dateOffset1).toLocaleTimeString().substring(0,Now.addDays(Item.dateOffset1).toLocaleTimeString().indexOf(':'))]]:[[0.concat(Now.getMinutes()).slice(-2)]] [[Now.addDays(Item.dateOffset1).getHours()<12 && 'AM' || 'PM']] [[Now.toTimeString().substr(Now.toTimeString().indexOf('(')+1,1))]][[Now.addDays(Item.dateOffset1).toTimeString().substr(Now.addDays(Item.dateOffset1).toTimeString().indexOf(' ', Now.addDays(Item.dateOffset1).toTimeString().indexOf('('))+1,1)]]T
By the way, I tested the AM/PM logic and it works fine.
timezonemath.rp (46.7 KB)