<?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: Convert timestamp in event to specific timezone in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577507#M201253</link>
    <description>&lt;P&gt;Unfortunately (or not - depending on how you look at it), there is no possibility to set a timezone different than your user's configured timezone for a single search. That's one.&lt;/P&gt;&lt;P&gt;And two - if there&amp;nbsp; is no timezone information within the parsed time string, it is parsed according to your local timezone. Makes sense.&lt;/P&gt;&lt;P&gt;So if you want to make sure the time string is parsed according to particular timezone, make sure it's included in the string and format your timespec string accordingly.&lt;/P&gt;&lt;P&gt;I'm not sure (would have to check but don't have access to my splunk at the moment) if "Z" is recognized or if you have to change it on the fly to UTC or GMT.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Dec 2021 18:42:52 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-12-06T18:42:52Z</dc:date>
    <item>
      <title>Convert timestamp in event to specific timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577504#M201251</link>
      <description>&lt;P&gt;Hey Splunk Gurus-&lt;/P&gt;&lt;P&gt;I'm attempting to calculate the duration between when an event was first identified (which is an entry in the event "alert.created_at") and the "_time" timestamp.&lt;/P&gt;&lt;P&gt;I'm able to calculate this timestamp difference using strptime("alert.created_at") but the conversion of that time to epoch is relative to the viewers timezone.&amp;nbsp; The duration changes based on how you configure the Splunk UI timezone.&lt;/P&gt;&lt;P&gt;The "_time" field is set to "current" in props.conf&lt;/P&gt;&lt;P&gt;Here's my current search:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* alert.tool.name=* action="fixed" 
| eval create_time=strptime('alert.created_at', "%Y-%m-%dT%H:%M:%SZ")  
| eval duration = _time - create_time &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a sample of the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "action": "fixed",
    "alert": {
        "number": 2,
        "created_at": "2021-11-22T23:49:19Z"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I execute this search while my UI preferences are set to "GMT" the result is 1183959 which is the correct duration.&amp;nbsp; When I set that preference to "PST", the result is&amp;nbsp;&lt;SPAN&gt;1155159.&amp;nbsp; That number is wrong by exactly 8 hours.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on how to deal with this?&amp;nbsp; I'm fine with either a search-time solution or a config change in props.conf if that's best.&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 18:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577504#M201251</guid>
      <dc:creator>leftrightleft</dc:creator>
      <dc:date>2021-12-06T18:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp in event to specific timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577507#M201253</link>
      <description>&lt;P&gt;Unfortunately (or not - depending on how you look at it), there is no possibility to set a timezone different than your user's configured timezone for a single search. That's one.&lt;/P&gt;&lt;P&gt;And two - if there&amp;nbsp; is no timezone information within the parsed time string, it is parsed according to your local timezone. Makes sense.&lt;/P&gt;&lt;P&gt;So if you want to make sure the time string is parsed according to particular timezone, make sure it's included in the string and format your timespec string accordingly.&lt;/P&gt;&lt;P&gt;I'm not sure (would have to check but don't have access to my splunk at the moment) if "Z" is recognized or if you have to change it on the fly to UTC or GMT.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 18:42:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577507#M201253</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-12-06T18:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp in event to specific timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577513#M201255</link>
      <description>&lt;P&gt;Yeah that's kinda my hang up.&amp;nbsp; The timestamp contains a "Z" which is part of the ISO 8601 definition.&amp;nbsp; I was really hoping strptime() would be able to recognize it.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 20:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577513#M201255</guid>
      <dc:creator>leftrightleft</dc:creator>
      <dc:date>2021-12-06T20:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp in event to specific timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577516#M201258</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;index=* alert.tool.name=* action="fixed"&lt;BR /&gt;| eval create_time=strptime('alert.created_at'."+00","%Y-%m-%dT%H:%M:%SZ%z")&lt;BR /&gt;| eval duration=_time-create_time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 20:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577516#M201258</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2021-12-06T20:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp in event to specific timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577519#M201260</link>
      <description>&lt;P&gt;It seems it is able to recognize it. In your strptime you don't use field code for timezone.&lt;/P&gt;&lt;P&gt;Check out my example - I render a local timestamp (I'm in CET, you might be somewhere else) but instead of my local timezone I add a constant "Z". Then I reparse the string with %Z interpreting timezone properly as UTC.&lt;/P&gt;&lt;PRE&gt;| makeresults &lt;BR /&gt;| eval time=strftime(_time, "%Y-%m-%d %H:%M:%SZ")&lt;BR /&gt;| eval _time=strptime(time, "%Y-%m-%d %H:%M:%S%Z")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 21:02:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577519#M201260</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-12-06T21:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Convert timestamp in event to specific timezone</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577542#M201268</link>
      <description>&lt;P&gt;It was as simple as getting that "%" in place.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 03:34:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-timestamp-in-event-to-specific-timezone/m-p/577542#M201268</guid>
      <dc:creator>leftrightleft</dc:creator>
      <dc:date>2021-12-07T03:34:19Z</dc:date>
    </item>
  </channel>
</rss>

