<?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 Convert from epoch returns wrong timezone? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Convert-from-epoch-returns-wrong-timezone/m-p/383808#M69086</link>
    <description>&lt;P&gt;Epoch/Unix times are always in UTC. &lt;/P&gt;

&lt;P&gt;When  I use &lt;CODE&gt;convert&lt;/CODE&gt; to create a human readable time, the timezone ( &lt;CODE&gt;%Z&lt;/CODE&gt; ) is somehow incorrect for some sourcetypes but correct for others. &lt;/P&gt;

&lt;P&gt;I realize the timezone on those sourcetypes &lt;EM&gt;may&lt;/EM&gt; be incorrect, but then the epoch time should reflect that. &lt;/P&gt;

&lt;P&gt;example &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;base search&amp;gt;
| stats latest(_time) as latest_epoch earliest(_time) as earliest_epoch by sourcetype
| convert timeformat="%x %X %Z" ctime(latest_epoch) AS latest_human
| convert timeformat="%x %X %Z" ctime(earliest_epoch) AS earliest_human
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This results in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   sourcetype      latest_epoch      earliest_epoch    earliest_human            latest_human
1  sourcetypeA     1553733248.762    1553718850.771    03/27/19 14:34:10 MDT     03/27/19 18:34:08 MDT
2  sourcetypeB     1553733250        1553733250        03/27/19 18:34:10 MDT     03/27/19 18:34:10 MDT
3  sourcetypeC     1553733253        1553733253        03/27/19 18:34:13 MDT     03/27/19 18:34:13 MDT
4  sourcetypeD     1553733250        1553718190.756    03/27/19 14:23:10 MDT     03/27/19 18:34:10 MDT
5  sourcetypeE     1553733250        1553733250        03/27/19 18:34:10 MDT     03/27/19 18:34:10 MDT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see rows 2,3 &amp;amp; 5 are correct. Rows 1 and 4 are not. However all rows have essentially the same epoch time. &lt;/P&gt;

&lt;P&gt;Epoch time is always in GMT, so why is it being converted to two different timezones yet also claiming to be MDT.&lt;/P&gt;

&lt;P&gt;What gives?&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2019 21:35:16 GMT</pubDate>
    <dc:creator>peterson_wwt</dc:creator>
    <dc:date>2019-03-28T21:35:16Z</dc:date>
    <item>
      <title>Convert from epoch returns wrong timezone?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Convert-from-epoch-returns-wrong-timezone/m-p/383808#M69086</link>
      <description>&lt;P&gt;Epoch/Unix times are always in UTC. &lt;/P&gt;

&lt;P&gt;When  I use &lt;CODE&gt;convert&lt;/CODE&gt; to create a human readable time, the timezone ( &lt;CODE&gt;%Z&lt;/CODE&gt; ) is somehow incorrect for some sourcetypes but correct for others. &lt;/P&gt;

&lt;P&gt;I realize the timezone on those sourcetypes &lt;EM&gt;may&lt;/EM&gt; be incorrect, but then the epoch time should reflect that. &lt;/P&gt;

&lt;P&gt;example &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;base search&amp;gt;
| stats latest(_time) as latest_epoch earliest(_time) as earliest_epoch by sourcetype
| convert timeformat="%x %X %Z" ctime(latest_epoch) AS latest_human
| convert timeformat="%x %X %Z" ctime(earliest_epoch) AS earliest_human
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This results in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   sourcetype      latest_epoch      earliest_epoch    earliest_human            latest_human
1  sourcetypeA     1553733248.762    1553718850.771    03/27/19 14:34:10 MDT     03/27/19 18:34:08 MDT
2  sourcetypeB     1553733250        1553733250        03/27/19 18:34:10 MDT     03/27/19 18:34:10 MDT
3  sourcetypeC     1553733253        1553733253        03/27/19 18:34:13 MDT     03/27/19 18:34:13 MDT
4  sourcetypeD     1553733250        1553718190.756    03/27/19 14:23:10 MDT     03/27/19 18:34:10 MDT
5  sourcetypeE     1553733250        1553733250        03/27/19 18:34:10 MDT     03/27/19 18:34:10 MDT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see rows 2,3 &amp;amp; 5 are correct. Rows 1 and 4 are not. However all rows have essentially the same epoch time. &lt;/P&gt;

&lt;P&gt;Epoch time is always in GMT, so why is it being converted to two different timezones yet also claiming to be MDT.&lt;/P&gt;

&lt;P&gt;What gives?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 21:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Convert-from-epoch-returns-wrong-timezone/m-p/383808#M69086</guid>
      <dc:creator>peterson_wwt</dc:creator>
      <dc:date>2019-03-28T21:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert from epoch returns wrong timezone?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Convert-from-epoch-returns-wrong-timezone/m-p/383809#M69087</link>
      <description>&lt;P&gt;What makes you think the timezones are wrong?&lt;/P&gt;

&lt;P&gt;Lines 1 &amp;amp; 4 have an earliest epoch time ~15000 seconds (or about 4.25 hours) earlier than their latest epoch time:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1  sourcetypeA     1553733248.762    1553718850.771       03/27/19 14:34:10 MDT     03/27/19 18:34:08 MDT
4  sourcetypeD     1553733250        1553718190.756       03/27/19 14:23:10 MDT     03/27/19 18:34:10 MDT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Those seem to be perfectly fine to me.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Sidebar - hadn't run into anyone using &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/convert"&gt;convert&lt;/A&gt; before: I've always used &lt;CODE&gt;| eval timefield=strftime(epochfield,"&amp;lt;format&amp;gt;")&lt;/CODE&gt; (and most often use &lt;CODE&gt;"%c"&lt;/CODE&gt; as my time formatter)&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 19:40:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Convert-from-epoch-returns-wrong-timezone/m-p/383809#M69087</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2019-10-17T19:40:31Z</dc:date>
    </item>
  </channel>
</rss>

