[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

Working with DATE in javascript

I need to check the date entered by user with the current date.  If the difference between dates is more than 3 days then I do not want user to update records. I am not able to understand how to manipulate this using DATE object. Please help
0
richaBhootra
Asked:
richaBhootra
1 Solution
 
IsisagateCommented:
Use the milliseconds...

var dateA; //old Date
var today = new Date();

var diffInMilliseconds = today.getTime() - dateA.getTime();

var millisecondsInADay = 86400000; //1000*60*60*24
if( diffInMilliseconds  >= 3*millisecondsInADay )
{
alert("3 days old");
}
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now