<?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: How do you set a human readable time format as earliest time? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426967#M74822</link>
    <description>&lt;P&gt;The problem with (accurately) converting to epoch is you need to know the timezone  for the timestamp.&lt;/P&gt;

&lt;P&gt;From the looks of your example, you don't have anything which indicates the TZ, so when you convert, it will assume UTC.&lt;/P&gt;

&lt;P&gt;If your events are coming from all over the world (and different timezones) this will be quite challenging, unless you can somehow work out from the source/host where the event came from.&lt;BR /&gt;
However, if your server(s) are all in one place you can 'manually' compensate for TZ by adding or subtracting 3600 for each hour.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval my_earliest_epoch=strptime(startTime, "%d-%m-%Y %H:%M:%S") + (3600 * 5)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: &lt;STRONG&gt;note&lt;/STRONG&gt; you have to invert the addition/subtraction vs the normal UTC notation. Ie, if your TZ is UTC-5 you have to &lt;STRONG&gt;ADD&lt;/STRONG&gt; 5 hours to epoch&lt;/P&gt;</description>
    <pubDate>Sat, 09 Mar 2019 10:38:01 GMT</pubDate>
    <dc:creator>nickhills</dc:creator>
    <dc:date>2019-03-09T10:38:01Z</dc:date>
    <item>
      <title>How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426965#M74820</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have one table that produces start time and end time in "%d-%m-%Y %H:%M:%S" (09-01-2019 07:44:05) format.&lt;/P&gt;

&lt;P&gt;My requirement is when we drilldown this table, it set this time as earliest and latest time for the dependent panel.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;drilldown&amp;gt;
      &amp;lt;eval token="time_token.earliest"&amp;gt;round(strptime($row.Reset_Start$, "%d-%m-%Y %H:%M:%S"),0)&amp;lt;/eval&amp;gt;
      &amp;lt;eval token="time_token.latest"&amp;gt;round(strptime($row.Reset_End$, "%d-%m-%Y %H:%M:%S"),0)&amp;lt;/eval&amp;gt;
      &amp;lt;set token="engine_id_token"&amp;gt;$row.Engine_ID$&amp;lt;/set&amp;gt;
      &amp;lt;set token="source_token"&amp;gt;$row.source$&amp;lt;/set&amp;gt;

 dependent search
&amp;lt;search&amp;gt;
&amp;lt;query&amp;gt; 
&amp;lt;/query&amp;gt;
&amp;lt;earliest&amp;gt;time_token.earliest&amp;lt;/earliest&amp;gt;
&amp;lt;latest&amp;gt;time_token.latest&amp;lt;/latest&amp;gt;
&amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Suppose  time is "09-01-2019 07:44:05" in table( say GMT timezone). When I access it from GMT+1 timezone  and convert it to epoch it automatically changes to  "09-01-2019 08:44:05". I don't want it to be changed. I want to keep same time for all users accross different time zone.&lt;/P&gt;

&lt;P&gt;One solution is to assign time without converting it to epoch but not sure if its possible.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 22:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426965#M74820</guid>
      <dc:creator>AKG1_old1</dc:creator>
      <dc:date>2019-03-08T22:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426966#M74821</link>
      <description>&lt;P&gt;can you share the XML? or the drill-down search ? &lt;BR /&gt;
your requirement is quite unclear to me . what exactly do you want when you drill-down from the image you have shown ?&lt;BR /&gt;
do you want to take the value of start and end time as it is and assign to some other field ? or you want as it is in the earliest and latest time?&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 03:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426966#M74821</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-03-09T03:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426967#M74822</link>
      <description>&lt;P&gt;The problem with (accurately) converting to epoch is you need to know the timezone  for the timestamp.&lt;/P&gt;

&lt;P&gt;From the looks of your example, you don't have anything which indicates the TZ, so when you convert, it will assume UTC.&lt;/P&gt;

&lt;P&gt;If your events are coming from all over the world (and different timezones) this will be quite challenging, unless you can somehow work out from the source/host where the event came from.&lt;BR /&gt;
However, if your server(s) are all in one place you can 'manually' compensate for TZ by adding or subtracting 3600 for each hour.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval my_earliest_epoch=strptime(startTime, "%d-%m-%Y %H:%M:%S") + (3600 * 5)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: &lt;STRONG&gt;note&lt;/STRONG&gt; you have to invert the addition/subtraction vs the normal UTC notation. Ie, if your TZ is UTC-5 you have to &lt;STRONG&gt;ADD&lt;/STRONG&gt; 5 hours to epoch&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 10:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426967#M74822</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2019-03-09T10:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426968#M74823</link>
      <description>&lt;P&gt;@mayurr98 I have updated the question with more details.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2019 15:28:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426968#M74823</guid>
      <dc:creator>AKG1_old1</dc:creator>
      <dc:date>2019-03-10T15:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426969#M74824</link>
      <description>&lt;P&gt;This comes from this other Q&amp;amp;A:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/590067/how-do-i-map-my-personally-tz-adjusted-time-to-ano.html"&gt;https://answers.splunk.com/answers/590067/how-do-i-map-my-personally-tz-adjusted-time-to-ano.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Here are the pieces of the puzzle:&lt;/P&gt;

&lt;P&gt;This shows you the TZ settings for your users (probably just you, unless you have admin):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rest/services/authentication/users/ splunk_server=local
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This shows you the possible TZ settings on your Search Head:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rest/servicesNS/-/search/data/ui/manager 
| regex eai:data="Time zone" 
| head 1 
| rename eai:data AS _raw 
| table _raw 
| rex mode=sed "s/(?ms)^.*Default System Timezone --\"\/&amp;gt;[\s\r\n]+(.*?)&amp;lt;\/options&amp;gt;.*$/\1/" 
| eval raw=split(_raw, "&amp;lt;opt value=") 
| mvexpand raw 
| rex field=raw "^\"(?&amp;lt;value&amp;gt;[^\"]+)\"\s+label=\"(?&amp;lt;label&amp;gt;[^\"]+)\"" 
| fields - _raw raw
| search label="*" AND value="*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what really does what we need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults 
| eval MYtime=strftime(_time, "%m/%d/%Y %H:%M:%S %Z")
| eval UTCtime=MYtime
| rex field=UTCtime mode=sed "s/\s+\S+$/ UTC/"
| eval UTC_time=strptime(UTCtime, "%m/%d/%Y %H:%M:%S %Z")
| eval TZdelta = round(_time - UTC_time, 0)
| eval TZdeltaDuration = if((TZdelta&amp;lt;0), "-", "") . tostring(abs(TZdelta), "duration")
| rename COMMENT AS "Calcluate 2 hourmin values: 1 personal which varies, and 1 UTC-normalized which does not"
| eval MYhourmin=strftime(_time, "%H%M")
| eval UTChourmin=strftime(_time + TZdelta, "%H%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You may have seen me gripe from time to time about the &lt;CODE&gt;date_*&lt;/CODE&gt; fields and here is why.  First of all, not all events have them; only those that have timestamps inside of the events.  But if your events &lt;EM&gt;do&lt;/EM&gt; have it, it is actually the thing that I am trying to fix here: it is a UTC/GMT-normalized value that is not normalized to your personal TZ setting.   So if my events had the &lt;CODE&gt;date_*&lt;/CODE&gt; values, I could have just used &lt;CODE&gt;date_hour&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2019 19:03:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426969#M74824</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-10T19:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426970#M74825</link>
      <description>&lt;P&gt;Thanks @woodcock  : This is really helpful.  for this issue I got one easy solution. but we have some other use case in which this can be useful. !!&lt;/P&gt;

&lt;P&gt;For this issue:&lt;BR /&gt;
Instead of converting to epoch time in drilldown, I am converting it in search query and magically I am getting what I want. Not sure though why I am getting different time when converting it in drilldown compare to search query. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**Search Query:**
| eval epoch_earliest= strptime(Reset_Start, "%d-%m-%Y %H:%M:%S")
| eval epoch_latest= strptime(Reset_End, "%d-%m-%Y %H:%M:%S")

**Drilldown:**
          &amp;lt;set token="tps_selection_earliest"&amp;gt;$row.epoch_earliest$&amp;lt;/set&amp;gt;
          &amp;lt;set token="tps_selection_latest"&amp;gt;$row.epoch_latest$&amp;lt;/set&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2019 12:01:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426970#M74825</guid>
      <dc:creator>AKG1_old1</dc:creator>
      <dc:date>2019-03-13T12:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do you set a human readable time format as earliest time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426971#M74826</link>
      <description>&lt;P&gt;That should work perfectly.  If not it is a bug.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 03:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-set-a-human-readable-time-format-as-earliest-time/m-p/426971#M74826</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-14T03:32:13Z</dc:date>
    </item>
  </channel>
</rss>

