Getting Data In

timestamp conversion

Jananee_iNautix
Path Finder

Hi ,
I want to convert the
Input :2013-12-09 18:11:34
Input :13-12-09 18:11:34
I want a common regex to convert the above format to the below format
Output:Thu December 2013 12 18:11:34.
I tried with the regex | eval m=strptime(timestamp,"%Y-%m-%d")|eval timestamp=strftime(m,"%B %Y")|table timestamp
But it is converting only the timestamp with the format 2013-12-09 18:11:34 and not 13-12-09 18:11:34.

Tags (1)
0 Karma
1 Solution

lguinn2
Legend

Try this

yoursearchhere
| eval outputTimestamp = if (match(timestamp,"\d{2}-\d{2}-\d{2} \d{2}\:\d{2}\:\d{2}"),
            strptime(timestamp,"%y-%m-%d %H:%M:%S"),strptime(timestamp,"%Y-%m-%d %H:%M:%S"))
| eval outputTimestamp = strftime(outputTimestamp,"%a %b %Y %d %H:%M:%S")
| table timestamp outputTimestamp

View solution in original post

Ayn
Legend

If these are timestamps in your input, aren't they the timestamp that Splunk uses in its own timestamp recognition? I think you might be making this more complicated than it needs to be.

lguinn2
Legend

Try this

yoursearchhere
| eval outputTimestamp = if (match(timestamp,"\d{2}-\d{2}-\d{2} \d{2}\:\d{2}\:\d{2}"),
            strptime(timestamp,"%y-%m-%d %H:%M:%S"),strptime(timestamp,"%Y-%m-%d %H:%M:%S"))
| eval outputTimestamp = strftime(outputTimestamp,"%a %b %Y %d %H:%M:%S")
| table timestamp outputTimestamp

Jananee_iNautix
Path Finder

Thanks a lot...it is working

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...