<?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 time format in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27376#M4606</link>
    <description>&lt;P&gt;I believe that you'll have to make a two stage operation, first convert your input format to &lt;CODE&gt;epoch&lt;/CODE&gt;, and the convert it to your desired format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval epochtime=strptime(your_current_time_field, "%b %d %H:%M:%S")| eval desired_time=strftime(epochtime, "%d/%m/%Y %I:%M:%S %p")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, since the data coming in has no year specification, I'm not sure that you would get usable results. It may be that you'll have to make changes to the logging application so that the full date is being logged.&lt;/P&gt;

&lt;P&gt;For information regarding &lt;CODE&gt;strftime&lt;/CODE&gt; and &lt;CODE&gt;strptime&lt;/CODE&gt;, see;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://strftime.org"&gt;http://strftime.org&lt;/A&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;Ah, ziegfried has an important point. If Splunk has read your timestamp (without the year) and parsed and indexed it correctly (you can compare the the timestamps in the events with the timestamp next to the blue down-arrow-thingy to the left of the event), then you can skip the first part and use the &lt;CODE&gt;_time&lt;/CODE&gt; field, which is already in &lt;CODE&gt;epoch&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval desired_time=strftime(_time, "%d/%m/%Y %I:%M:%S %p")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps somewhat anyway,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
    <pubDate>Mon, 16 Apr 2012 10:49:45 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2012-04-16T10:49:45Z</dc:date>
    <item>
      <title>convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27374#M4604</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;In splunk query i  need to convert time format as below .&lt;/P&gt;

&lt;P&gt;Current format  - Apr 13 17:58:35&lt;/P&gt;

&lt;P&gt;Required Format : 04/13/2012 5:58:35 PM&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 10:23:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27374#M4604</guid>
      <dc:creator>Ravan</dc:creator>
      <dc:date>2012-04-16T10:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27375#M4605</link>
      <description>&lt;P&gt;Is it the timestamp, that is recognized by Splunk or do you have an extracted field with this value?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 10:47:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27375#M4605</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-16T10:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27376#M4606</link>
      <description>&lt;P&gt;I believe that you'll have to make a two stage operation, first convert your input format to &lt;CODE&gt;epoch&lt;/CODE&gt;, and the convert it to your desired format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval epochtime=strptime(your_current_time_field, "%b %d %H:%M:%S")| eval desired_time=strftime(epochtime, "%d/%m/%Y %I:%M:%S %p")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, since the data coming in has no year specification, I'm not sure that you would get usable results. It may be that you'll have to make changes to the logging application so that the full date is being logged.&lt;/P&gt;

&lt;P&gt;For information regarding &lt;CODE&gt;strftime&lt;/CODE&gt; and &lt;CODE&gt;strptime&lt;/CODE&gt;, see;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.1/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.1/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://strftime.org"&gt;http://strftime.org&lt;/A&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;Ah, ziegfried has an important point. If Splunk has read your timestamp (without the year) and parsed and indexed it correctly (you can compare the the timestamps in the events with the timestamp next to the blue down-arrow-thingy to the left of the event), then you can skip the first part and use the &lt;CODE&gt;_time&lt;/CODE&gt; field, which is already in &lt;CODE&gt;epoch&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval desired_time=strftime(_time, "%d/%m/%Y %I:%M:%S %p")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps somewhat anyway,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 10:49:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27376#M4606</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-16T10:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27377#M4607</link>
      <description>&lt;P&gt;Here is how to create a new field by parsing and formatting a date value using Splunk's eval command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval newdatefield = strftime( strptime( myolddatefield, "%b %d %H:%M:%S" ), "%m/%d/%Y %I:%M:%S %p")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;UL&gt;
&lt;LI&gt;use &lt;CODE&gt;strptime()&lt;/CODE&gt; to parse a timestamp value&lt;/LI&gt;
&lt;LI&gt;use &lt;CODE&gt;strftime()&lt;/CODE&gt;to format a timestamp value&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 16 Apr 2012 11:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27377#M4607</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-16T11:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27378#M4608</link>
      <description>&lt;P&gt;Cool , its  working great. Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 12:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27378#M4608</guid>
      <dc:creator>Ravan</dc:creator>
      <dc:date>2012-04-16T12:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27379#M4609</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I used it for my purposes and it worked.&lt;BR /&gt;
Thank you very much!&lt;/P&gt;

&lt;P&gt;Skender Kollcaku&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2015 15:32:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/27379#M4609</guid>
      <dc:creator>skender27</dc:creator>
      <dc:date>2015-06-30T15:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert time format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/579302#M102273</link>
      <description>&lt;P&gt;the docs link seems to be broken,.. hence replying link again..&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchReference/CommonEvalFunctions" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;strftime's "Date and time format variables" docs link...&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchReference/Commontimeformatvariables" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 12:06:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/convert-time-format/m-p/579302#M102273</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2021-12-27T12:06:26Z</dc:date>
    </item>
  </channel>
</rss>

