silversurfer
"a day ago" just means it was pasted "yesterday". It doesn't mean "24 hours before now".
Where can i see/get the current server datetime? (to know its been 24 hours since the last post).
Answer to rest of question:
I'll try to post a separate thread if this didn't make clear for LLD ( Low Level Design),
In short you save user setting once (at time of user creation {timezone} at user_details table .
Typical scenario session/JWT
- When user re-login , you get the user data along with time diff and store it on his session.
- When ever you display any page , convert server time to user local time.
The save part goes via normal ( no functionality changed , you store on server timestamp , updated/created post).
Considering scalability and performance its definitely would take O(1) for converting one timestamp to other while display, for N conversion its O(N) not more than that.
Whyy constant?
Since difference (server time - user time ) remains constant.
Also you can store at any server timestamp as long you have timezone of it. Even if you move from one region to other the timezone remains the same. getDate(STORED_TIMESTAMP,new TimeZone("STORED_TIMEZONE"));
( would move this to database if it is optimal) or you can also come with basic rules of your own to store every entry timestamp as GMT.
btw ,
timestamp are calculated from seconds diff from Jan 1 1970 midnight (GMT) to current time.
BUMP!