<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add clock to a panel dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358567#M23341</link>
    <description>&lt;P&gt;Yes, this will always show client time, because JavaScript runs in the browser, not on the server. If you want server time, you'll need a query that gets sent to the server. I don't know off-hand what the right query would be for that, so this would make a good follow-up question presented in its own Answers post. Probably nobody will see the question buried here in comments, especially since the original question has been answered.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Apr 2018 14:29:37 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2018-04-25T14:29:37Z</dc:date>
    <item>
      <title>Add clock to a panel dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358563#M23337</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I was wondering how can I create a panel with only a clock on it.&lt;BR /&gt;
I tried to insert a html code an then add a javascript file but the panel is still empty.&lt;/P&gt;

&lt;P&gt;xml dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="clock.js"&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;div class="clock"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;clock.js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([

    "splunkjs/ready!",

    "splunkjs/mvc/simplexml/ready!"

],
function clock() {// We create a new Date object and assign it to a variable called "time".
var time = new Date(),

    // Access the "getHours" method on the Date object with the dot accessor.
    hours = time.getHours(),

    // Access the "getMinutes" method with the dot accessor.
    minutes = time.getMinutes(),


    seconds = time.getSeconds();

document.querySelectorAll('.clock')[0].innerHTML = harold(hours) + ":" + harold(minutes) + ":" + harold(seconds);

  function harold(standIn) {
    if (standIn &amp;lt; 10) {
      standIn = '0' + standIn
    }
    return standIn;
  }
}
setInterval(clock, 1000);
);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Did I miss something? &lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 14:31:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358563#M23337</guid>
      <dc:creator>csimonnet</dc:creator>
      <dc:date>2018-04-24T14:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Add clock to a panel dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358564#M23338</link>
      <description>&lt;P&gt;The syntax of your JS is a little off. I cleaned it up here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
  "splunkjs/ready!",
  "splunkjs/mvc/simplexml/ready!"
], function() {
  function clock() {// We create a new Date object and assign it to a variable called "time".
    var time = new Date(), hours = time.getHours(), minutes = time.getMinutes(), seconds = time.getSeconds();
    document.querySelectorAll('.clock')[0].innerHTML = harold(hours) + ":" + harold(minutes) + ":" + harold(seconds);

    function harold(standIn) {
      if (standIn &amp;lt; 10) {
        standIn = '0' + standIn
      }
      return standIn;
    }
  }
setInterval(clock, 1000);
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After you've fixed your JS, you'll need to use the _bump function to get Splunk to pick up the new JS. So you'll visit http(s)://your.server.here:port/en-US/_bump &lt;BR /&gt;
You can read more about using _bump here:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/CustomizationOptions" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/CustomizationOptions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:14:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358564#M23338</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2020-09-29T19:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add clock to a panel dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358565#M23339</link>
      <description>&lt;P&gt;Thanks!&lt;BR /&gt;
It works&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 09:24:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358565#M23339</guid>
      <dc:creator>csimonnet</dc:creator>
      <dc:date>2018-04-25T09:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add clock to a panel dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358566#M23340</link>
      <description>&lt;P&gt;But it shows your client time (Time in which your browser is running)..&lt;BR /&gt;&lt;BR /&gt;
May be not inline with your data always. Please try to get server time..&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 10:46:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358566#M23340</guid>
      <dc:creator>paramagurukarth</dc:creator>
      <dc:date>2018-04-25T10:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Add clock to a panel dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358567#M23341</link>
      <description>&lt;P&gt;Yes, this will always show client time, because JavaScript runs in the browser, not on the server. If you want server time, you'll need a query that gets sent to the server. I don't know off-hand what the right query would be for that, so this would make a good follow-up question presented in its own Answers post. Probably nobody will see the question buried here in comments, especially since the original question has been answered.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 14:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Add-clock-to-a-panel-dashboard/m-p/358567#M23341</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-25T14:29:37Z</dc:date>
    </item>
  </channel>
</rss>

