[Webinar] Streamline your web hosting managementRegister Today

  • 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
1 Solution
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");

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