Check If A Date Is More Than 1 Hour Ago

Posted by Weston Ganger

Javascript can be a bit difficult to work with time without a library but heres two simple ways to check a date.

This example shows checking if myDate is more than an hour from the current time.


var oneHour = 60 * 60 * 1000;
if((new(Date) - myDate) > oneHour){
  // do work
}

Another example is to get the time one hour from the current time.


var oneHour = 60 * 60 * 1000;
new Date(new(Date) + oneHour);


Related External Links:

Article Topic:Software Development - Javascript

Date:June 16, 2016

Recommended Posts