Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Content Fragment | How to save the date in author given time zone

sharms13
Level 2
Level 2

Hi All,

 

We have a content fragment template which has date field  and Time Zone dropdown. Now our requirement is that when the author selects a date and the time zone we want the date to be saved in the author selected time zone format.

For example , if author has entered date as "May 21,2021 11:29 am" and selected Time zone as "UTC+8: Hong Kong, Beijing, Kaula Lumpur"  then instead of saving the date  as "2021-05-21T11:29:00.000+05:30" it should be saved like "2021-05-21T11:29:00.000+08:00"  which is author selected time zone format.

 

One approach we are planning is to invoke a listener or a javascript function when the author tries to save the content fragment.

 

Please suggest if anyone has come up with the similar kind of use-case and solved it. Also the approach taken to achieve the same.

1 Accepted Solution
rush_pawan
Correct answer by
Community Advisor
Community Advisor

Hello,

 

We went through this and our approach was

 

- rather changing the time and saving author specific time zone better to keep the server time zone (to keep common across for business logic and use cases) and calculate it based on client location while rendering the content. benefit we saw was a common client side solution to handle time zone difference and was applicable for any such rendering to content rather writing complex logic to figure out each different saved time zone according to author and then calculate these for a end user time zone.

 

i hope, i was able to clarify. hope this helps!!

 

thanks.

 

 

View solution in original post

2 Replies
rush_pawan
Correct answer by
Community Advisor
Community Advisor

Hello,

 

We went through this and our approach was

 

- rather changing the time and saving author specific time zone better to keep the server time zone (to keep common across for business logic and use cases) and calculate it based on client location while rendering the content. benefit we saw was a common client side solution to handle time zone difference and was applicable for any such rendering to content rather writing complex logic to figure out each different saved time zone according to author and then calculate these for a end user time zone.

 

i hope, i was able to clarify. hope this helps!!

 

thanks.

 

 

View solution in original post

sharms13
Level 2
Level 2

Hi Pawan,

Thanks for the reply but rendering side we have a scenario where we need to render the fragment in a sorted order based on the date. Now if we have a server time, then showing the content to end user which is sorted based on the server time whereas the date and time which they are viewing is localize or based on the timezone they have selected.