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

  • Home
  • SEARCH
  • 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 9038443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:29:27+00:00 2026-06-16T09:29:27+00:00

Okay , im want to make something like facebook’s auto time increment for posts

  • 0

Okay , im want to make something like facebook’s auto time increment for posts and notificaitons etc.
when the post arrived for example , 5 seconds ago.

How do i use jQuery to make it auto increase without having to parse server for timeago.

It can increase till hours and days.

I have found a script , and tried modifying it , but its not working:
Any jquery plugin which automatic update time for all the posts of a page

$.fn.UpdateSince = function(interval) {

    var times = this.map(function(){ return { e: $(this), t: parseInt($(this).html()) }; });

    var format = function(t) {
        if (t > 60) {
            return Math.floor(t / 60) + ' minutes ago'
        } else if(t > 3600){
            return Math.floor(t / 3600) + ' hours ago'
        } else if(t > 86400){
            return Math.floor(t / 86400) + ' days ago'
        } else {
            return t + ' seconds ago';
        }
    }

    var update = function(){
        $.each(times, function(i, o){
            o.e.html(format(Math.round((o.t + 1000))));
        });
    };

    window.setInterval(update, interval);
    update();

    return this;
}

$('.TimeSince').UpdateSince(1000);
  • 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-06-16T09:29:28+00:00Added an answer on June 16, 2026 at 9:29 am

    It looks like you removed the now variable from the original script, which needs to know what time it is in order to run!

    The getTime() method returns a value from your system clock – not the server.

    Incidentally, you should reverse the order of the conditional in your code – put “days” first, then “hours”, then “minutes”:

    if(t > 86400) {
        return Math.floor(t / 86400) + ' days ago';
    } else if(t > 3600) {
        return Math.floor(t / 3600) + ' hours ago';
    } else if(t > 60) {
        return Math.floor(t / 60) + ' minutes ago';
    } else {
        return t + ' seconds ago';
    }
    

    Otherwise, the function will always return “seconds” if t is greater than 60.

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

Sidebar

Related Questions

Okay, so I want to make a polling site but it doesn't work like
Okay the thing i want to do is make a variable like Line =
Okay, so I want to do something like this: int array[] = {1, 2,
Okay so I want to make an application that launches other applications. However, the
Okay, so I was looking for something like answered here . The only problem
Okay, so I'm trying to make a full text search in multiple columns, something
My plugin takes some time doing something. So I want to listen to when
Okay, so Im trying to replace a line like this 00010 (0x000A) with something
I want to make chain-calling like jquery-way in c++. The sample: $('#obj').getParent().remove(); So, as
Okay so here is what I want to do. I want to add a

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.