<?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 the timezone from a time field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28491#M5646</link>
    <description>&lt;P&gt;Ok. Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2013 23:24:53 GMT</pubDate>
    <dc:creator>lain179</dc:creator>
    <dc:date>2013-05-08T23:24:53Z</dc:date>
    <item>
      <title>Convert the timezone from a time field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28487#M5642</link>
      <description>&lt;P&gt;I have a field extracted from log entries, containing time values in GMT. Can I convert the field to PST time? If so, how can I accomplish that?&lt;BR /&gt;
&lt;BR /&gt;&lt;/P&gt;

&lt;PRE&gt;
stats values(SearchUser) as User values(SearchStartDate) as "Start" values(SearchEndDate) as "End" by Project, SearchID
&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;SearchStartDate&lt;/STRONG&gt; and &lt;STRONG&gt;SearchEndDate&lt;/STRONG&gt; need to be converted to PST.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2013 21:18:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28487#M5642</guid>
      <dc:creator>lain179</dc:creator>
      <dc:date>2013-05-08T21:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert the timezone from a time field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28488#M5643</link>
      <description>&lt;P&gt;One way would be to make use of the &lt;CODE&gt;strptime()/strftime()&lt;/CODE&gt; functions of &lt;CODE&gt;eval&lt;/CODE&gt;, which will let you convert time from strings, e.g. 2013-05-03 12:23:34 to &lt;CODE&gt;epoch&lt;/CODE&gt; (which is the time expressed as the number of seconds since midnight Jan 1, 1970). While that might seem odd, it makes addition/subtraction very easy.&lt;/P&gt;

&lt;P&gt;So. Let's assume that your timestamps look like above, but for the wrong timezone, you can do like this;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search 
| eval start_e = strptime(SearchStartDate, "%Y-%m-%d %H:%M:%S") +36000 
| eval SearchStartDate = strftime(start_e, "%Y-%m-%d %H:%M:%S") 
| eval end_e = strptime(SearchEndDate, "%Y-%m-%d %H:%M:%S") +36000 
| eval SearchEndDate = strftime(end_e, "%Y-%m-%d %H:%M:%S") 
| the rest of your search as shown in your question
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The 36000 is just the number of seconds (10 hours) which is the difference between the two timezones. NB. This is just my guessing, I don't remember if it's eight or nine hours diff.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;strptime()&lt;/CODE&gt; makes the string into an integer, according to the specification&lt;BR /&gt;
&lt;CODE&gt;strftime()&lt;/CODE&gt; turns the number back into a string, according to the specification&lt;/P&gt;

&lt;P&gt;Also, note that this will NOT change any data in the event, but just modify how it's presented.&lt;/P&gt;

&lt;P&gt;Please see the following for more info;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Commontimeformatvariables"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.strftime.net"&gt;http://www.strftime.net&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps, &lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2013 22:07:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28488#M5643</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-08T22:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Convert the timezone from a time field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28489#M5644</link>
      <description>&lt;P&gt;I guess there is no function to convert the time directly instead of doing the Math?&lt;/P&gt;

&lt;P&gt;Actually the time values in logs are in UTC. Because of the daylight saving, the difference is sometimes 7 hours and sometimes is 8 hours. So adding a constant number won't work too well.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2013 22:16:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28489#M5644</guid>
      <dc:creator>lain179</dc:creator>
      <dc:date>2013-05-08T22:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Convert the timezone from a time field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28490#M5645</link>
      <description>&lt;P&gt;I recommend setting your &lt;STRONG&gt;TZ&lt;/STRONG&gt; (timezone) settings for each one of your sources or sourcetypes.  Splunk will do the math for you. However this &lt;STRONG&gt;will not work on previously indexed data&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2013 22:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28490#M5645</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2013-05-08T22:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Convert the timezone from a time field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28491#M5646</link>
      <description>&lt;P&gt;Ok. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2013 23:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28491#M5646</guid>
      <dc:creator>lain179</dc:creator>
      <dc:date>2013-05-08T23:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Convert the timezone from a time field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28492#M5647</link>
      <description>&lt;P&gt;Well, the TZ setting will AFAIK only work on the timestamp used for indexing purposes, so-to-speak, i.e. not for any other time data inside the events.&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2013 14:30:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-the-timezone-from-a-time-field/m-p/28492#M5647</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-12T14:30:22Z</dc:date>
    </item>
  </channel>
</rss>

