Timezone Offset of the dashboard user

You can use new Date() in the ui-template node to get the browser time. You can also use getTimezoneOffset() to get time zone.

example when you land on dashboard the template should return iso timestamp and offset in mins

[{"id":"1f94fb5c.5fe375","type":"ui_ui_control","z":"e67b04df66bd0437","name":"","events":"all","x":190,"y":660,"wires":[["12852117.09e36f"]]},{"id":"12852117.09e36f","type":"function","z":"e67b04df66bd0437","name":"","func":"msg.template = `<script>\nvar btime =  new Date();\nthis.scope.send({btime: btime, offset: btime.getTimezoneOffset()});\n</script>`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":700,"wires":[["9e7f00ae.6ac08"]]},{"id":"9e7f00ae.6ac08","type":"ui_template","z":"e67b04df66bd0437","group":"2d4fe667.28f8ba","name":"","order":5,"width":0,"height":0,"format":"","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","className":"","x":490,"y":640,"wires":[["2ca4bfc8.35ce5"]]},{"id":"2ca4bfc8.35ce5","type":"debug","z":"e67b04df66bd0437","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":620,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like