Answer the question
In order to leave comments, you need to log in
Where and how is it better to make a request to the server or is it not needed?
Task: News is displayed on the main page. It is necessary, depending on the time zone (time) of the user, to adjust the news time values. yii project.
If you write ajax in the form, it means that the request will go twice, and this is bad.
I would not want to redraw ready-made news with js, because on the server to correct the time - a couple of lines, and on the client you have to recalculate a lot + there are widgets on the page.
What is the best way to do this and where?
News format:
Date
Time - news
Time - news
Number
Time - news
Time - news
Answer the question
In order to leave comments, you need to log in
1. Wrap the date string, for example, in <span>
2. inside the span, make the data-date attribute
<span data-date="тут метка времени из базы"></span>
Additional overgrowth is not needed. Why do you not like the timezone definition on the client and what is the problem with widgets?
https://jsfiddle.net/j5veLew4/
Format the output - a couple more lines. If it's difficult - you can use moment.js
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question