0

I have json file that is of that format. in Php i created variable that writes time in this format date(h:i:s) to file everytime its being overwritten.

{"Time":"11:01:57","Temperature":"21.00","Temperature2":"69.80","Humidity":"49.00"}

In client side I want using jquery compare this time from file wtih current time. For example if the difference is lets say 5 minutes then execute something. I dont know how to aproach this

1 Answers1

0

Assumption:

  1. Only time matters and date does not.
  2. Also Timezone are the same.

    var startTime = Date.parse('11:01:57'); //Get today date and set time to this
    var now = new Date; //Get today date 
    var difference = (now - startTime); //Calculate difference in milliseconds
    

JSFiddle

planet260
  • 1,384
  • 1
  • 14
  • 30