Forum Discussion

duddys's avatar
duddys
Icon for Helper I rankHelper I
1 year ago
Solved

Live clock in pbi report

Hi, what is the easiest way to create live clock for my report? Iam in the need because I dont want to refresh the report to get the time, I need it live.
  • Bibiano_Geraldo's avatar
    Bibiano_Geraldo
    1 year ago

    Hi, change the font color for black:

    HTMLContentClock = 
    "
    <div style='
        width: 100%; 
        height: 100%; 
        padding: 15px; 
        border-radius: 10px; 
        color: black; 
        font-family: Arial, sans-serif; 
        font-size: 30px; 
        font-weight: bold; 
        text-align: center;'>
        <div id='clock'></div>
        <script type='text/javascript'>
            function updateClock() {
                var now = new Date();
                var hours = now.getHours();
                var minutes = now.getMinutes();
                var seconds = now.getSeconds();
                var timeString = hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
                document.getElementById('clock').innerHTML = timeString;
            }
            
            // Update the clock every 1000 milliseconds (1 second)
            setInterval(updateClock, 1000);
            
            // Initial clock update
            updateClock();
        </script>
    </div>
    "