<?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 How to convert a date time field to epoch time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220495#M64794</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I am looking to format my current time to epoch time (as we need to calculate some math function on time)&lt;/P&gt;

&lt;P&gt;Time format  for &lt;STRONG&gt;incidentEndTimeStr&lt;/STRONG&gt; looks like this: &lt;CODE&gt;4/11/16 2:52&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;And used the eval command and strptime function below to change the format, but it doesn't work. Can you please assist?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval incidentEndTime = strptime(incidentEndTimeStr, "%m/%d/%Y %I:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval incidentEndTime = strptime(incidentEndTimeStr, "%m/%d/%Y %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2016 20:50:18 GMT</pubDate>
    <dc:creator>splunker9999</dc:creator>
    <dc:date>2016-08-09T20:50:18Z</dc:date>
    <item>
      <title>How to convert a date time field to epoch time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220495#M64794</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I am looking to format my current time to epoch time (as we need to calculate some math function on time)&lt;/P&gt;

&lt;P&gt;Time format  for &lt;STRONG&gt;incidentEndTimeStr&lt;/STRONG&gt; looks like this: &lt;CODE&gt;4/11/16 2:52&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;And used the eval command and strptime function below to change the format, but it doesn't work. Can you please assist?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval incidentEndTime = strptime(incidentEndTimeStr, "%m/%d/%Y %I:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval incidentEndTime = strptime(incidentEndTimeStr, "%m/%d/%Y %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:50:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220495#M64794</guid>
      <dc:creator>splunker9999</dc:creator>
      <dc:date>2016-08-09T20:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a date time field to epoch time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220496#M64795</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;strptime(incidentEndTimeStr, "%-m/%-d/%y %-H:%-M") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's a working sample&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval x="4/11/16 2:52" | eval t=strptime(x, "%-m/%-d/%y %-H:%-M") | eval z=strftime(t, "%-m/%-d/%y %-H:%-M") | table x t z
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:57:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220496#M64795</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-09T20:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a date time field to epoch time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220497#M64796</link>
      <description>&lt;P&gt;The problem is the year that it's composed by only two digits, so you have to use "%y" instead "%Y".&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 06:40:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220497#M64796</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-08-10T06:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a date time field to epoch time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220498#M64797</link>
      <description>&lt;P&gt;if you're satisfied of the answer, please, accept the answer.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 11:17:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-date-time-field-to-epoch-time/m-p/220498#M64797</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-09-09T11:17:43Z</dc:date>
    </item>
  </channel>
</rss>

