<?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 Conversion to UNIX time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368025#M163086</link>
    <description>&lt;P&gt;I want to convert my default _time field to UNIX/Epoch time and have it in a different field. This is how the Time field looks now.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2/7/18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;3:35:10.531 AM&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2018 08:36:19 GMT</pubDate>
    <dc:creator>zacksoft</dc:creator>
    <dc:date>2018-02-07T08:36:19Z</dc:date>
    <item>
      <title>Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368025#M163086</link>
      <description>&lt;P&gt;I want to convert my default _time field to UNIX/Epoch time and have it in a different field. This is how the Time field looks now.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2/7/18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;3:35:10.531 AM&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 08:36:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368025#M163086</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-02-07T08:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368026#M163087</link>
      <description>&lt;P&gt;That's just how _time automatically get's presented, under the hood, it is still a UNIX timestamp value. So you can simply do:&lt;BR /&gt;
    | eval mytime=_time&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368026#M163087</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-29T17:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368027#M163088</link>
      <description>&lt;P&gt;If it is internally represented at epoch time, then can math functions be applied to _time field directly ? i.e. new_time = _time + 30m  ('new_time' is the time after 30 minutes) ..something like this ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368027#M163088</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368028#M163089</link>
      <description>&lt;P&gt;_time is already in epoch format...&lt;BR /&gt;
so try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval time=strftime(_time,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but if time is in different field then try this run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval time="2/7/18 3:35:10.531 AM"|eval Time=strptime(time,"%m/%d/%y %I:%M:%S.%3N %p")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 08:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368028#M163089</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-07T08:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368029#M163090</link>
      <description>&lt;P&gt;Can I perform math functions like add/subtract to the time field after  using&lt;BR /&gt;
|eval time=strftime(_time,"%Y-%m-%d %H:%M:%S")  ?&lt;/P&gt;

&lt;P&gt;example new_time = time +39s    ??&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 08:58:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368029#M163090</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-02-07T08:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368030#M163091</link>
      <description>&lt;P&gt;so you have to convert min into sec. and then add. here 30m=30*60sec&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;new_time=_time+1800|eval new_time=strftime(new_time,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 08:59:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368030#M163091</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-07T08:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368031#M163092</link>
      <description>&lt;P&gt;so you have to convert min into sec. and then add. here 30m=30*60sec&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;new_time=_time+1800|eval new_time=strftime(new_time,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Feb 2018 08:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368031#M163092</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-07T08:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368032#M163093</link>
      <description>&lt;P&gt;you have to perform math before &lt;CODE&gt;strftime&lt;/CODE&gt; function&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 09:02:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368032#M163093</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-07T09:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion to UNIX time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368033#M163094</link>
      <description>&lt;P&gt;hey @zacksoft&lt;/P&gt;

&lt;P&gt;You can use strftime(X,Y) to convert in a specified time format in Y and &lt;CODE&gt;strptime(X,Y)&lt;/CODE&gt; to convert the same in epoch time.&lt;BR /&gt;
have a look at this doc &lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/DateandTimeFunctions#strftime.28X.2CY.29"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/DateandTimeFunctions#strftime.28X.2CY.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;For time format, you can have a look at this doc&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Try this run anywhere search for more:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 end=20 
| eval Endtime=strftime(endtime,"%d/%m/%Y %H:%M:%S"),Starttime=strftime(starttime,"%d/%m/%Y %H:%M:%S"),Starthuman=strptime(starthuman,"%a %b %d %H:%M:%S %Y"),Endhuman=strptime(endhuman,"%a %b %d %H:%M:%S %Y") 
| table starttime Starttime endtime Endtime starthuman Starthuman endhuman Endhuman
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 09:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conversion-to-UNIX-time/m-p/368033#M163094</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-02-07T09:51:46Z</dc:date>
    </item>
  </channel>
</rss>

