<?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 Display time in UTC in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79977#M16450</link>
    <description>&lt;P&gt;We are trying to run a report that groups data by the UTC date of events occur. Our Heavy forwarders collect the data from different regions and correctly set the TZ field according to the time fields from the source data. We can tell that this is correct, because the value of the _time field is the epoch time of the events in UTC.&lt;/P&gt;

&lt;P&gt;When we run the report, we use strftime(_time, "%Y-%m-%d") to get the date that the event occurred. The problem is that this appears to be reporting the date according to the local representation of the indexer. We know this, because if we add %z to the time format it shows different timezones for each indexer. If we add a map function like "stats" to the command prior to computing the strftime we get the timezone of the search head.&lt;/P&gt;

&lt;P&gt;What we want to do is to create a string that represent the UTC date of the event regardless of what timezone the indexer or search head is running on. Since this is a very common scenario for us, is there a configuration setting or search function that can ensure that UTC time is used to render the date?&lt;/P&gt;</description>
    <pubDate>Mon, 27 Feb 2012 22:17:52 GMT</pubDate>
    <dc:creator>rtkelly</dc:creator>
    <dc:date>2012-02-27T22:17:52Z</dc:date>
    <item>
      <title>Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79977#M16450</link>
      <description>&lt;P&gt;We are trying to run a report that groups data by the UTC date of events occur. Our Heavy forwarders collect the data from different regions and correctly set the TZ field according to the time fields from the source data. We can tell that this is correct, because the value of the _time field is the epoch time of the events in UTC.&lt;/P&gt;

&lt;P&gt;When we run the report, we use strftime(_time, "%Y-%m-%d") to get the date that the event occurred. The problem is that this appears to be reporting the date according to the local representation of the indexer. We know this, because if we add %z to the time format it shows different timezones for each indexer. If we add a map function like "stats" to the command prior to computing the strftime we get the timezone of the search head.&lt;/P&gt;

&lt;P&gt;What we want to do is to create a string that represent the UTC date of the event regardless of what timezone the indexer or search head is running on. Since this is a very common scenario for us, is there a configuration setting or search function that can ensure that UTC time is used to render the date?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 22:17:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79977#M16450</guid>
      <dc:creator>rtkelly</dc:creator>
      <dc:date>2012-02-27T22:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79978#M16451</link>
      <description>&lt;P&gt;One way is to set the timezone on your indexers and search heads to UTC. Do this in the OS, and Splunk will render the timezone in UTC by default.&lt;/P&gt;

&lt;P&gt;In Splunk 4.3, each user can choose their own timezone for viewing the data/reports/etc. Go to &lt;STRONG&gt;Manager » Access controls » Users&lt;/STRONG&gt; to set this for users, or to &lt;STRONG&gt;Manager » Your account&lt;/STRONG&gt; to set the timezone for yourself.&lt;/P&gt;

&lt;P&gt;Note that Splunk always stores the data in UTC in the index, but displays it according to the indexer's TZ or the users's TZ.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 22:40:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79978#M16451</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-02-27T22:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79979#M16452</link>
      <description>&lt;P&gt;Thanks. We were thinking about switching all the servers to run in UTC time. We were also thinnking of upgraing to 4.3 soon. We'd like to run the scheduled searches from app context. Would there be a preferred timezone for an app?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 23:05:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79979#M16452</guid>
      <dc:creator>rtkelly</dc:creator>
      <dc:date>2012-02-27T23:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79980#M16453</link>
      <description>&lt;P&gt;No you can't set timezone by app - sorry. I think it's great if you can have all your servers in UTC - it simplifies management from the OS across the whole software stack. But that's just a personal preference.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 23:08:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79980#M16453</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-02-27T23:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79981#M16454</link>
      <description>&lt;P&gt;I think that splunk needs a search line command to override the time zone settings in the client for that search, much like "earliest" and "latest" overrides the UI time settings for the search.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2015 18:35:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79981#M16454</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-01-28T18:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79982#M16455</link>
      <description>&lt;P&gt;I was faced with the same problem recently and I solved it by writing the following macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[strftime_utc(2)]
args = field, format
definition = "strftime($field$ - (strptime(strftime($field$, \"%Y-%m-%dT%H:%M:%SZ\"), \"%Y-%m-%dT%H:%M:%S%Z\")-strptime(strftime($field$, \"%Y-%m-%dT%H:%M:%S\"), \"%Y-%m-%dT%H:%M:%S\")), \"$format$\")"
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So you can now write a search that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main | eval utc_time=`strftime_utc(_time, "%Y-%m-%dT%H:%M:%SZ")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regardless of what the timezone is on each event, this will cause the output to be in UTC.&lt;/P&gt;

&lt;P&gt;Thanks to @richgalloway for the initial suggestion that lead to this.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 18:07:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/79982#M16455</guid>
      <dc:creator>asieira</dc:creator>
      <dc:date>2017-04-07T18:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/560643#M92660</link>
      <description>&lt;P&gt;Little late but you can try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| eval offset=strftime(_time,"%z")
| eval _time=_time-(offset*36)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 23 Jul 2021 19:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/560643#M92660</guid>
      <dc:creator>bhatti009</dc:creator>
      <dc:date>2021-07-23T19:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Display time in UTC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/690980#M114947</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/116615"&gt;@asieira&lt;/a&gt;&amp;nbsp; I tried this query but not working for me and getting&amp;nbsp;&lt;SPAN&gt;Error in 'eval' command: The expression is malformed. An unexpected character is reached at `\"%Y-%m-%dT%H:%M:%SZ\"), \`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;same macro:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[strftime_utc(2)]
args = field, format
definition = strftime($field$ - (strptime(strftime($field$, \"%Y-%m-%dT%H:%M:%SZ\"), \"%Y-%m-%dT%H:%M:%S%Z\")-strptime(strftime($field$, \"%Y-%m-%dT%H:%M:%S\"), \"%Y-%m-%dT%H:%M:%S\")), \"$format$\")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;SPAN&gt;now my search looks like:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;*My query* | eval utc_time=`strftime_utc(_time, "%Y-%m-%dT%H:%M:%SZ")`&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 10:59:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Display-time-in-UTC/m-p/690980#M114947</guid>
      <dc:creator>abhinav_go</dc:creator>
      <dc:date>2024-06-18T10:59:46Z</dc:date>
    </item>
  </channel>
</rss>

