JSFiddle - React, Tailwind, and code Playground

HTML

<div id='timer'></div>

CSS

#timer{
    border: solid thin blue;
    font-size:15px;
}

JavaScript

//waiting for the device to be ready to start working on phonegap
document.addEventListener("deviceready", onDeviceReady, false);

var onDeviceReady = function(){
    //executing the backgroundMode plugin
    window.plugin.backgroundMode.enable();
    testFunction.periodical(500);
}

 //function to test if the code is being executed on the BG
var dateObj = new Date();
var previousTimer = dateObj.getTime() / 1000;
var testFunction = function(){
    var newTimer = dateObj.getTime() / 1000;
    if(newTimer !== previousTimer){
        var timerText = dateObj.getHours() + ":";
        timerText += dateObj.getMinutes() + ":";
        timerText += dateObj.getSeconts();
        $('timer').set('text',timerText);
    }
}