My code is working properly in Google Chrome, but not in Safari.
I figured out that I need to convert yyyy-MM-dd HH:mm:ss
to ISO 8601
, but I didn't found a solution to do this.
Online Test Link: http://jsfiddle.net/UVgHR/
Javascript:
$(document).ready(function() {
calculateMinutes();
setInterval(calculateMinutes, 60000);
});
function calculateMinutes() {
$('.calculateMinutes').each(function () {
var diff = Math.abs(new Date( $(this).data('timestamp') ) - new Date());
var minutes = Math.floor((diff/1000)/60);
$(this).html( minutes + ' min.' );
});
}
HTML Example:
<span class="calculateMinutes" data-timestamp="2014-02-18 15:00:48">