JSFiddle - React, Tailwind, and code Playground

JavaScript

var log_time1 = '2017-07-15 09:30:46';//Examples of ISO format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.

var log_time = new Date(log_time1)//string parsing date

var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year =  currentDate.getFullYear()
var hour =  currentDate.getHours(); // => 9
var minute= currentDate.getMinutes(); // =>  30
var second= currentDate.getSeconds(); // => 51


var today = year + "-" + month + "-" + day
var time =  hour + ":" + minute + ":" + second
var date1 = (log_time);
var test_date2 = (today+' '+time);

var date2= new Date(test_date2);//string parsing date

var hours = Math.abs(date2 - date1) / 36e5;
alert(hours.toFixed(2))