<?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: How can I get now() to be in UTC? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228717#M14172</link>
    <description>&lt;P&gt;One minor note -  @lguinn said "the data is always stored in the index with _time in UTC", but this is confusing and not technically true.  Splunk stores the _time in "epochtime" , meaning as the number of seconds since 12am 1/1/1970 in gmt. &lt;BR /&gt;
On the other hand "UTC" is a timezone,  so to store time "in UTC" would technically mean to store it as a string that looks something like "Tue, 04 Oct 2016 02:38:31 UTC".&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2016 02:40:45 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2016-10-04T02:40:45Z</dc:date>
    <item>
      <title>How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228709#M14164</link>
      <description>&lt;P&gt;Seems like such a trivial question but I can't find the answer.&lt;/P&gt;

&lt;P&gt;I'm new to Splunk and troubleshooting a dashboard set up by someone else. He was using "now() - _time" to show "Data Freshness" - however _time is in UTC in the incoming data, so I just need now() to be in UTC as well. How do I do that in the search?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 22:17:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228709#M14164</guid>
      <dc:creator>cwapshere</dc:creator>
      <dc:date>2016-10-03T22:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228710#M14165</link>
      <description>&lt;P&gt;Try something like this. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval x=now() | eval pst=strptime(strftime(x,"%m/%d/%Y %H:%M:%S UTC"),"%m/%d/%Y %H:%M:%S %Z") | eval mst=strptime(strftime(x,"%m/%d/%Y %H:%M:%S MST"),"%m/%d/%Y %H:%M:%S %Z")  | eval est=strptime(strftime(x,"%m/%d/%Y %H:%M:%S EST"),"%m/%d/%Y %H:%M:%S %Z") | eval utc=strptime(strftime(x,"%m/%d/%Y %H:%M:%S UTC"),"%m/%d/%Y %H:%M:%S %Z") | table x pst mst est utc | foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=strftime(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, "%c")]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Oct 2016 23:29:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228710#M14165</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-03T23:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228711#M14166</link>
      <description>&lt;P&gt;Thanks for that. I tried a simplified version which just ave me the UTC time I wanted:&lt;/P&gt;

&lt;P&gt;eval nowutc=strptime(strftime(now(),"%m/%d/%Y %H:%M:%S UTC"),"%m/%d/%Y %H:%M:%S %Z") | eval result = nowutc - _time &lt;/P&gt;

&lt;P&gt;But the resultant number is the same as I get from this:&lt;/P&gt;

&lt;P&gt;eval result=now() - _time&lt;/P&gt;

&lt;P&gt;I'm starting to think the issue is _time and not now(). Eg., I have a panel showing "Last Event Was 27 Hours Ago" when I have events from 16 hours ago - and I am in UTC+11. All the data files are in JSON format with a _time field, for every event, in UTC. Now I'm thinking splunk is interpreting that as local time...&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 00:07:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228711#M14166</guid>
      <dc:creator>cwapshere</dc:creator>
      <dc:date>2016-10-04T00:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228712#M14167</link>
      <description>&lt;P&gt;Have you tried the &lt;CODE&gt;reltime&lt;/CODE&gt; command?  It may give you what you're looking for&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/Reltime"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/Reltime&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;_time&lt;/CODE&gt; is always stored as epoch time and then converted to the timezone specified in .conf files. &lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 00:15:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228712#M14167</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-04T00:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228713#M14168</link>
      <description>&lt;P&gt;It's kind of a mindbending question,  but I think the answer is this -  _time is an epochtime value, and that's also what now() returns.   ie a number of seconds since the "epoch" started, which is in turn defined as 12am on 1/1/1970 if you were standing in GMT at that moment. &lt;/P&gt;

&lt;P&gt;The Splunk UI itself will automatically convert _time to be in local time, and this can lead to a misunderstanding that _time is itself a string value.    Which can in turn lead to confusing attempts to convert it to another timezone like UTC. &lt;/P&gt;

&lt;P&gt;hth&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 00:17:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228713#M14168</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-10-04T00:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228714#M14169</link>
      <description>&lt;P&gt;I think there may be an issue with the splunk forwarder assuming the incoming _time values are local instead of UTC.&lt;/P&gt;

&lt;P&gt;I'm going to see if I can figure out how to get at the raw value because I can't change the forwarder at this time. Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 01:11:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228714#M14169</guid>
      <dc:creator>cwapshere</dc:creator>
      <dc:date>2016-10-04T01:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228715#M14170</link>
      <description>&lt;P&gt;I think you have most of this from the other answers, but let me summarize:&lt;/P&gt;

&lt;P&gt;When the data comes from a forwarder, the forwarder (version 6.x) supplies local time zone information that Splunk uses to calculate _time in UTC. So, the data is always stored in the index with _time in UTC. If the data does not have the proper time, it &lt;EM&gt;may&lt;/EM&gt; be because the Splunk admin who set up the forwarding missed something. Perhaps the time zone information is not being picked up somewhere along the way, or props.conf needs to have a timezone setting on the indexer. You can find more info here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/Data/HowSplunkextractstimestamps"&gt;How timestamp assignment works&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;That said - when you sign onto Splunk, there is a time zone associated with your user account. So if you had your user timezone set to Pacific Time, then the Splunk UI will &lt;STRONG&gt;display&lt;/STRONG&gt; all times (including &lt;CODE&gt;_time&lt;/CODE&gt; and &lt;CODE&gt;now()&lt;/CODE&gt;) in Pacific Time. So what you see may well be different from the value that is actually stored, but it will be consistent.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval freshness = now() - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Calculates "freshness" as  the number of seconds between the event timestamp and the time that the search started.&lt;/P&gt;

&lt;P&gt;Finally, you might also try the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Reltime"&gt;reltime&lt;/A&gt; command for what you want. (If I understand what you want.)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| head 1
| reltime 
| eval output="Last event was " . reltime
| table output
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Creates a field named "output" which displays stuff like "Last event was 27 seconds ago." And you don't have to do the math yourself.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 01:44:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228715#M14170</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-10-04T01:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228716#M14171</link>
      <description>&lt;P&gt;Wow thanks for the great explanation! I know sundareshr had also suggested reltime but when I looked at the doc I couldn't understand why it had no argumates - was still thinking I needed to feed it two dates. That does seem to have worked.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 02:28:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228716#M14171</guid>
      <dc:creator>cwapshere</dc:creator>
      <dc:date>2016-10-04T02:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get now() to be in UTC?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228717#M14172</link>
      <description>&lt;P&gt;One minor note -  @lguinn said "the data is always stored in the index with _time in UTC", but this is confusing and not technically true.  Splunk stores the _time in "epochtime" , meaning as the number of seconds since 12am 1/1/1970 in gmt. &lt;BR /&gt;
On the other hand "UTC" is a timezone,  so to store time "in UTC" would technically mean to store it as a string that looks something like "Tue, 04 Oct 2016 02:38:31 UTC".&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 02:40:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-get-now-to-be-in-UTC/m-p/228717#M14172</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-10-04T02:40:45Z</dc:date>
    </item>
  </channel>
</rss>

