Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3753162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:21:00+00:00 2026-05-19T09:21:00+00:00

In Facebook and twitter, we can see that there is a timestamp like 23

  • 0

In Facebook and twitter, we can see that there is a timestamp like “23 seconds ago” or “1 hour ago” for each event & tweet. If we leave the page for some time, the timestamp changes accordingly.

Since it is possible that user machine doesn’t have same system time as server machine, how to make the dynamic timestamp accurate?

My idea is:
It is always based on server time. When request is sent to server for the web page, timestamp T1 (seconds to 1970/1/1) is rendered into inline javascript variable. The displayed timestamp (“23 seconds ago”) is calculated by T1 instead of local time.

I’m not sure whether this is how Facebook/Twitter do it. Is there any better idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:21:00+00:00Added an answer on May 19, 2026 at 9:21 am

    This is what happens with Facebook: when someone makes a post, Facebook records the timestamp from the server’s clock. When the information is displayed to the user, this timestamp is sent to them; however, the live “X seconds/minutes/hours ago” label is based on the client’s clock. You can test this by opening Facebook and looking at some recent news feed items, then changing your system’s clock — you will see that the labels will soon update to match the difference based on your system clock.

    However, if you refresh the page, the correct time difference will once again be displayed, even though your system clock is still wrong, thus it seems to be based on a time difference sent by the server as well.

    Reasoning from that, I would say that they send the time difference from the server, then, the live labels are updated using that value along with a difference calculated using the client’s clock.

    Here is a detailed example of what I mean::

    1. An item is posted at 14 Jan 2011 14:40:26 (server time)
    2. A user loads the news feed at 14 Jan 2011 14:40:42 (server time)
    3. Facebook sends the current time difference on the server. (Difference between 14 Jan 2011 14:40:26 and 14 Jan 2011 14:40:42 is 16 seconds)
    4. The page loads in the client’s browser. According to the client’s computer, the time is 14 Jan 2011 14:47:03, and is recorded using JavaScript. (Server time is still 14 Jan 2011 14:40:42)
    5. The initial label is populated with the value from the server and now says “16 seconds ago”
    6. Time passes. The client’s clock now says 14 Jan 2011 14:47:25. (Server time is now 14 Jan 2011 14:41:04)
    7. The client-side time difference is calculated: difference between 14 Jan 2011 14:47:03 and 14 Jan 2011 14:47:25 is 22 seconds
    8. The live label is updated using the server time difference, plus the client time difference (16 seconds + 22 seconds) and the label now says “38 seconds ago”

    The actual difference between the initial timestamp from the server (14 Jan 2011 14:40:26) and the current server time (14 Jan 2011 14:41:04) is 38 seconds, so you can see that even though the client’s clock was wrong, it was still possible to calculate an accurate time difference using this method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see that when connecting services to twitter/facebook, sometimes apps are storing the user
Users can use their Google, Facebook or Twitter account to login to a site
i am using hybridauth to get userinformation from social web sites like facebook,twitter, etc.
i am using hybridauth to get userinformation from social web sites like facebook,twitter, etc.
Ok, I really know what is it. I work with Facebook/Twitter API long ago.
I'm trying to use the official Facebook and Twitter buttons together. I'd like to
So I have an app account in which it can login using facebook/twitter or
I am developing an application that requires login with social media (Facebook, twitter). From
I'd like to move facebook and twitter buttons and make them more visible on
I've got a custom built news page that can cross post articles to Facebook

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.