<?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: converting time to utc with &amp;quot;%Y-%m-%dT%H:%M:%S.%3fZ format in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339029#M163243</link>
    <description>&lt;P&gt;Hi @dtakacssplunk,&lt;BR /&gt;
Try this run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval pageStartTime = "1517281593"|eval pageStartTimeDateTime=strftime(pageStartTime, "%Y-%m-%dT%H:%M:%S.%f%Z"), 
to_tz="UTC",from_tz="PST",
   from_t=strptime(strftime(pageStartTime, "%c.%6N " . from_tz), "%c.%6N %Z"),
   to_t=strptime(strftime(pageStartTime, "%c.%6N " . to_tz), "%c.%6N %Z"),
   offset=round((from_t-to_t)/60/60),
   converted=strftime(pageStartTime + (from_t-to_t), "%c")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here PST time is converted into UTC&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2018 03:11:43 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-01-30T03:11:43Z</dc:date>
    <item>
      <title>converting time to utc with "%Y-%m-%dT%H:%M:%S.%3fZ format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339028#M163242</link>
      <description>&lt;P&gt;Hello I'm trying to convert an epoach time to the UTC time.  I tried the following:&lt;/P&gt;

&lt;P&gt;e.g. pageStartTime = 1517275826849&lt;BR /&gt;
eval pageStartTimeDateTime=strftime(pageStartTime/1000, "%Y-%m-%dT%H:%M:%S.%f%Z")  =&amp;gt; 2018-01-29T17:30:26.849000PST&lt;BR /&gt;
eval pageStartTimeDateTime2=strftime((pageStartTime)/1000, "%Y-%m-%dT%H:%M:%S.%3f%z") =&amp;gt; 2018-01-29T17:30:26.849-0800&lt;/P&gt;

&lt;P&gt;Note both have timezone qualifier which I do not want I want to have it in UTC.&lt;/P&gt;

&lt;P&gt;How do I convert it so that the timestamp is something like this (utc time):&lt;BR /&gt;
e.g .  1517275826849   =&amp;gt;  2018-01-30T01:30:26.849Z &lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 02:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339028#M163242</guid>
      <dc:creator>dtakacssplunk</dc:creator>
      <dc:date>2018-01-30T02:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to utc with "%Y-%m-%dT%H:%M:%S.%3fZ format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339029#M163243</link>
      <description>&lt;P&gt;Hi @dtakacssplunk,&lt;BR /&gt;
Try this run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval pageStartTime = "1517281593"|eval pageStartTimeDateTime=strftime(pageStartTime, "%Y-%m-%dT%H:%M:%S.%f%Z"), 
to_tz="UTC",from_tz="PST",
   from_t=strptime(strftime(pageStartTime, "%c.%6N " . from_tz), "%c.%6N %Z"),
   to_t=strptime(strftime(pageStartTime, "%c.%6N " . to_tz), "%c.%6N %Z"),
   offset=round((from_t-to_t)/60/60),
   converted=strftime(pageStartTime + (from_t-to_t), "%c")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here PST time is converted into UTC&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 03:11:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339029#M163243</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-30T03:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to utc with "%Y-%m-%dT%H:%M:%S.%3fZ format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339030#M163244</link>
      <description>&lt;P&gt;Thanks!  is there any simpler way to do this?  &lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 23:07:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339030#M163244</guid>
      <dc:creator>dtakacssplunk</dc:creator>
      <dc:date>2018-01-30T23:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: converting time to utc with "%Y-%m-%dT%H:%M:%S.%3fZ format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339031#M163245</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count | eval PageStartTime = 1517360016 | eval offset = tonumber(strftime(now(),"%z"))/100*3600 | eval PageStartTimeUTC = PageStartTime - offset | eval PageStartTimeUTC = strftime(PageStartTimeUTC,"%d/%m/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Explanation: PageStartTime is given a test value. offset is calculated by getting current user's timezone offset - converting it in seconds and subtracting it from the current time. If you're in a negative time zone subtraction will be converted to addition as a - (-b) = a + b. So the last PageStartTimeUTC shows the time in UTC &lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 01:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/converting-time-to-utc-with-quot-Y-m-dT-H-M-S-3fZ-format/m-p/339031#M163245</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2018-01-31T01:03:14Z</dc:date>
    </item>
  </channel>
</rss>

