Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

difference in days

 
asif Shaikh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I calculate the number of days left of a future date from the current date?
 
Devaka Cooray
Marshal
Posts: 5184
503
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using java.util.Date,
futureDay.getTime() - today.getTime() returns the number of milliseconds between today and the 'future'.
Do some maths to get the number of days from it.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that doesn't work with Daylight Savings Time.

Search this forum, this question has been asked and answered (among others by me) several times before.
 
Bring out your dead! Or a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!