cancel
Showing results for 
Search instead for 
Did you mean: 

How to adopt users time settings in mails?

steffen_weber
Employee
Employee
0 Kudos

Hi experts,

we need to comunicate a specific date & time to multiple users by email directly from HCP backend.

Date and time is stored in UTC on HCP side, but of course it would be much more conveniant for the mail recipients to see the times directly in their local time format, like for us in Germany UTC+1.

Any thoughts on how to achieve this?

Regards, Steffen

View Entire Topic
former_member182372
Active Contributor
0 Kudos

Dont really understand the problem. javascript Date obejct has timezone adjustment.

If you know your users timzone you can do something like

new Date(date.getTime() + new Date().getTimezoneOffset()*60*1000);

steffen_weber
Employee
Employee
0 Kudos

Hi Maksim,

thanks. You think that we should calculate the actual time via JavaScript in the HTML mail itself?

Do you have an exmple for such an email which can be interpreted correctly by outlook and also all other mail clients for Win, Mac, iOS, Andorid an so on?

former_member182372
Active Contributor
0 Kudos

Unfortunatelly  i dont have such example.

If the mail body has javascript (and it is allowed to execute it), javascript date object should work fine and no extra calculation is needed, UTC time will be converted to proper local time. I ususally do someting like this

eval('new ' + datestr.replace(/\//g, ''))

where datestr is OData formatted date property ( "/Date(694224000000)/" )

steffen_weber
Employee
Employee
0 Kudos

Hi, unfortunately JS in HTML mail body is not allowed inside SAP ....

Qualiture
Active Contributor
0 Kudos

If the dates are stored on HCP, and the users (and their timezones) too, then why not use the power of HCP (Java) to get a personalized date?

api - Java: How do you convert a UTC timestamp to local time? - Stack Overflow

steffen_weber
Employee
Employee
0 Kudos

Hi Robin,

thanks, but unfortunately we don't store the users timezones in HCP.

Maybe a good approach, but prerequisites that every single user maintained it correctly previously.

Also not easy to achieve I fear...

Steffen