<?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 Timestamp from one format to UNIX style format in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412366#M118907</link>
    <description>&lt;P&gt;You can try using this command to format  &lt;CODE&gt;_time&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval time_field=strftime(_time,"%Y-%m-%d %H:%M:%S.%6N")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Jun 2019 01:56:34 GMT</pubDate>
    <dc:creator>alonsocaio</dc:creator>
    <dc:date>2019-06-11T01:56:34Z</dc:date>
    <item>
      <title>Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412365#M118906</link>
      <description>&lt;P&gt;I have a log file that has the timestamp for each line as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Jun 10, 11:07:59.305475
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that the year is missing - it is inferred from file name... or something...&lt;BR /&gt;
I am good with deriving year from now()&lt;/P&gt;

&lt;P&gt;I would like to convert it to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2019-6-10 11:07:59.305475
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Might there be a way to accomplish this when creating a field extraction?&lt;/P&gt;

&lt;P&gt;I have had no luck with startime &lt;/P&gt;

&lt;P&gt;Thanks for any clues!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 22:20:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412365#M118906</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-10T22:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412366#M118907</link>
      <description>&lt;P&gt;You can try using this command to format  &lt;CODE&gt;_time&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval time_field=strftime(_time,"%Y-%m-%d %H:%M:%S.%6N")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jun 2019 01:56:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412366#M118907</guid>
      <dc:creator>alonsocaio</dc:creator>
      <dc:date>2019-06-11T01:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412367#M118908</link>
      <description>&lt;P&gt;Hi dowdag,&lt;BR /&gt;
You have to convert two times your timestamp, try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval time_field=strftime(strptime(_time,"%B %d, %H:%M:%S.%6N"),"%Y-%m-%d %H:%M:%S.%6N")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 06:40:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412367#M118908</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-11T06:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412368#M118909</link>
      <description>&lt;P&gt;Hi @dowdag, Are you trying to achieve this using props.conf or you want to do this using a Splunk search?&lt;BR /&gt;
What I can tell is you are already extracting timestamp using props.conf and you want to add a year to it?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 12:11:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412368#M118909</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2019-06-11T12:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412369#M118910</link>
      <description>&lt;P&gt;Extracted "date time string" data from log:   Jun 06, 11:10:04.307625&lt;/P&gt;

&lt;P&gt;I added a lookup table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MonthAbrv, MonthNumber
Jan,01 
Feb,02
Mar,03
etc....

| rex field=TimeStamp "(?&amp;lt;Month&amp;gt;\w+)"
| lookup MonthStrToNum MonthAbrv as Month OUTPUT MonthNumber
| rex field=TimeStamp "\w+\s(?&amp;lt;day&amp;gt;\d+)"
| eval year=strftime(now(), "%Y") 
| rex field=TimeStamp "^.+,\s(?&amp;lt;Time&amp;gt;[\d:.]+)"
| eval DateTimeStr= (year . "-". MonthNumber . "-" . day ." " . Time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;DateTimeStr: 2019-06-06 11:10:04.307625&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval uxTimeStamp=strftime(strptime(DateTimeStr, "%Y-%m-%d %H:%M:%S:%3N"), "%Y-%m-%d %H:%M:%S:%3N")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However &lt;STRONG&gt;uxTimeStamp&lt;/STRONG&gt; is NULL -- what might I have missed?&lt;/P&gt;

&lt;P&gt;Thanks for any help &lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 18:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412369#M118910</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-11T18:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412370#M118911</link>
      <description>&lt;P&gt;Hi @dowdag,&lt;/P&gt;

&lt;P&gt;You are defining wrong format for DateTimeStr when converting it into epoch time. Please try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval uxTimeStamp=strftime(strptime(DateTimeStr, "%Y-%m-%d %H:%M:%S.%6N"), "%Y-%m-%d %H:%M:%S:%3N")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See how your DateTimeStr value is &lt;CODE&gt;2019-06-06 11:10:04.307625&lt;/CODE&gt; and as per your format in &lt;CODE&gt;strptime&lt;/CODE&gt; i.e. &lt;CODE&gt;%Y-%m-%d %H:%M:%S:%3N&lt;/CODE&gt; means you are expecting DateTimeStr to be &lt;CODE&gt;2019-06-06 11:10:04:307&lt;/CODE&gt; which will result in uxTimeStamp being NULL value.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Harsh&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 04:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412370#M118911</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2019-06-12T04:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Timestamp from one format to UNIX style format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412371#M118912</link>
      <description>&lt;P&gt;@dowdag &lt;BR /&gt;
Please try this:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/751096/convert-timestamp-from-one-format-to-unix-style-fo.html?childToView=751844#answer-751844"&gt;https://answers.splunk.com/answers/751096/convert-timestamp-from-one-format-to-unix-style-fo.html?childToView=751844#answer-751844&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 04:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-Timestamp-from-one-format-to-UNIX-style-format/m-p/412371#M118912</guid>
      <dc:creator>harshpatel</dc:creator>
      <dc:date>2019-06-12T04:59:22Z</dc:date>
    </item>
  </channel>
</rss>

