diff --git a/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js b/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js
index b163aac5..ba390511 100644
--- a/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js
+++ b/web/pgadmin/static/js/sqleditor/calculate_query_run_time.js
@@ -10,24 +10,25 @@
 import moment from 'moment';
 
 export function calculateQueryRunTime(startTime, endTime) {
-  const tempEndDate = moment(endTime);
-  let miliseconds = tempEndDate.diff(startTime);
-  let seconds = tempEndDate.diff(startTime, 'seconds');
-  const minutes = tempEndDate.diff(startTime, 'minutes');
-
+  let total_ms = moment(endTime).diff(startTime);
   let result = '';
-  if (minutes > 0) {
-    result += minutes + ' min ';
-    seconds -= minutes * 60;
-  }
+  let secs, mins, hrs;
+
+  /* Extract seconds from millisecs */
+  secs = parseInt(total_ms/1000);
+  total_ms = total_ms%1000;
+
+  /* Extract mins from seconds */
+  mins = parseInt(secs/60);
+  secs = secs%60;
 
-  if (seconds > 0) {
-    result += seconds + ' secs ';
-    miliseconds -= seconds * 1000;
-  }
+  /* Extract hrs from mins */
+  hrs = parseInt(mins/60);
+  mins = mins%60;
 
-  if(minutes <= 0) {
-    result += miliseconds + ' msec';
-  }
+  result = (hrs>0 ? hrs + ' hr ': '')
+          + (mins>0 ? mins + ' min ': '')
+          + (hrs<=0 && secs>0 ? secs + ' secs ': '')
+          + (hrs<=0 && mins<=0 ? total_ms + ' msec ':'');
   return result.trim();
 }
diff --git a/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js b/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js
index e5a58fe9..5d41813f 100644
--- a/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js
+++ b/web/regression/javascript/sqleditor/calculate_query_run_time_spec.js
@@ -79,4 +79,27 @@ describe('#calculateQueryRunTime', () => {
           .toEqual('9 min 54 secs');
     });
   });
+
+  describe('time difference is bigger then 1 hour', () => {
+    it('displays seconds, milliseconds', () => {
+      let startDate = moment({
+        years:2018,
+        months:4,
+        date:2,
+        hours:10,
+        minutes:30,
+        seconds:20,
+        milliseconds:123}).toDate();
+      let endDate = moment({
+        years:2018,
+        months:4,
+        date:2,
+        hours:11,
+        minutes:40,
+        seconds:15,
+        milliseconds:70}).toDate();
+      expect(calculateQueryRunTime(startDate, endDate))
+          .toEqual('1 hr 9 min');
+    });
+  });
 });
