Software Enthusiastic
Software Enthusiastic

Reputation: 26425

Sliding Duration with Javascript or JQuery

Can anyone please suggest, from given date how to calculate sliding duration in javascript or jquery...

I need following output..

- Article published 2 seconds back.
- Article publieshed 1 day back.
- Last modified 3 weeks back..
- Last mondified 1 month back...

Thank you very much.

Upvotes: 0

Views: 155

Answers (3)

Dan Grossman
Dan Grossman

Reputation: 52372

Take the time in seconds, and divide it by the number of seconds in a year, and that's how many years. Subtract that then divide it by the number of seconds in a month, and that's how many months. Subtract that then divide it by the number of seconds in a week... etc.

Upvotes: 0

Yi Jiang
Yi Jiang

Reputation: 50105

You're looking for a plugin that does relative or friendly dates. I would recommend the timeago jQuery plugin for this.

Upvotes: 1

kobe
kobe

Reputation: 15835

jquery animate can do many things.please go through the below api

http://api.jquery.com/animate/

you can even use interval

setInterval(function() //

Upvotes: 0

Related Questions