/    Sign up×
Community /Pin to ProfileBookmark

Countdown timer between dates

Hi All,

I have developed a application in jsp. I need to achieve a count down timer(days,hours,minutes,seconds) between from date to todate, considering below cases.

All below are assumed

(1) I have 4 product, for each product i have different end date stored in mysql in DB.

(2) I need to calculate time time remaining for the end date for each product, for eg;

Product 1 end date : 10/05/2010 (i need to show the time remaining for the end of 10/05/2010 from current time and date). Like wise i need to show for different products.

How to achieve this. Solutions for this would be highly appreciated. Thanks in advance.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@3NexMay 08.2010 — Well, you're not going to calculate the remaining time in javascript, that would be silly. You do that in JSP. Then just call the javascript function giving it days, hours, minutes and seconds as arguments and then create a javascript timer.

Javascript timer should be fairly easy. Each second you set seconds as current seconds minus one, then check if seconds are less than zero - if so, set seconds to 59 and minutes as minutes minus one, then check if minutes are less than zero - if so, set minutes to 59 and set days as days minus one etc...

Does that help? I hope I didn't understand your problem wrong.
Copy linkTweet thisAlerts:
@tirnaMay 08.2010 — if you google "calculate difference between 2 dates php" you'll get plenty of code examples on how to calculate the time difference between 2 dates.

You can also use a similar search criteria to find scripts to do it locally using javascript.
Copy linkTweet thisAlerts:
@pradeepktgauthorMay 15.2010 — Hi All,

I searched a lot, but am not able to find out the solution for this. How to calculate the time difference in jsp?

@3Nex, do you have idea about calculate the remaining time in jsp? If so, could you please gpost me the code?
Copy linkTweet thisAlerts:
@criterion9May 15.2010 — I did a quick search for "jsp timestamp" and found lots in the first page of hits...

http://www.coderanch.com/t/293577/JSP/java/Date-Timestamp-comparison
×

Success!

Help @pradeepktg spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...