Set a time in the title bar

Hello, I am trying to set a time in the titlebar and logo. I got it with this tutorial in this page

But when conect in browser tv samsung, the clock gets wrong. Gets 01/31/1969 23:45 for example. Othe devices its very good, for example, pc or raspian. How could i modify this code to get the time directly from my raspian, not local clock.

Maybe this can be of some help:

[{"id":"87d00364.32326","type":"ui_template","z":"bf2231d1.a01cf","group":"","name":"Logo / Clock","order":2,"width":0,"height":0,"format":"<script id=\"clockScript1\" type=\"text/javascript\">\n    var clockInterval;\n    $(function () {\n        if (clockInterval) return;\n\n        //add logo\n        var div1 = $('<div/>');\n        var logo = new Image();\n\n        logo.src = ''\n        logo.height = 45;\n        div1[0].style.margin = '10px auto';\n\n        div1.append(logo);\n\n        //add clock\n        var div2 = $('<div/>');\n        var p = $('<p/>');\n\n        div2.append(p);\n        div2[0].style.margin = '5px';\n\n        function displayTime() {\n            p.text(new Date().toLocaleString());\n        }\n        \n        clockInterval = setInterval(displayTime, 1000);\n\n        //add to toolbar when it's available\n        var addToToolbarTimer;\n        \n        function addToToolbar() {\n            var toolbar = $('.md-toolbar-tools');\n            \n            if(!toolbar.length) return;\n            \n            toolbar.append(div1);\n            toolbar.append(div2);\n            clearInterval(addToToolbarTimer);\n        }\n        addToToolbarTimer = setInterval(addToToolbar, 100);\n    });\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"global","x":330,"y":240,"wires":[[]]}]

This is my actual code. Thanks my friends

codigo atual.txt (1.1 KB)

Hello friend, thank you for fast answer. But not success.
The time on TV still remains wrong

As the script is client side, the time on your TV must be incorrect.

Is there a way of setting the time on your TV menus?

Does the clock advance as it should, even though it is showing the wrong time?

Since a time of zero in javascript is 00:00 1st January 1970 UTC that suggests that the browser starts with a time of zero (which might be 23:00 in your time zone for example).

Hello my friends, thanks for your answers. See, the times on my TV's menus are correct. For other devices the time is also correct. But on Samsung TV, start UTC with time zero (00:00 1970). It is possible to make a javascript code that obtains the same time as the raspbarry as it obtains the logo (IP raspian How do you get the server time, in this case the raspbarry?

Thanks, Best regards

This is my actual code.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.