How to set user timezone-aware timestamps

Hello,

I have a timestamp/datetime field which I would like to initialize to a value supplied by a system method (if there is such an existing method) that automatically “senses” the user’s timezone set in the User (=SEC_USER) entity or defaults to my pre-set timezone if there is none.

Currently it’s coded like this:

myUser.setAccountValidatedTs(new Date());

Thanks.

Hi,

According to the docs, if you set a DateTime attribute to a value in the server timezone (as you do now), it will be presented in DateTimeField and Table visual components in the user’s timezone. Isn’t it what you need?

Hi Konstantin @knstvk ,

Thank you for the link, it’s part of what I’m looking for. I have a follow-up query, I’m developing a Polymer client app which I understand is unlike the DateTimeField/Table components, and I would like to know what is your recommendation of converting the server timezone to the user’s timezone and vice versa with the Polymer UI?

Thanks again.

Hi, any update? Thanks.

Hi,
Sorry for the late response, you can use moment js in order to perform such conversions on client.