Splunk Search

How to convert this time format with strptime()?

Sundried
Explorer

I haven't found something for this time format in the docs:

Mon Sep 28 00:00:00 GMT 2020

How can I convert this with strptime()? How do I make sure the "GMT" part of the string isn't interfering?

Labels (1)
Tags (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Depends on what you mean by interfering, but this will parse the date into GMT

| makeresults
| eval _time=strptime("Mon Sep 28 00:00:00 GMT 2020", "%a %b %d %T %Z %Y")

and this will parse the date to your local time

| makeresults
| eval _time=strptime("Mon Sep 28 00:00:00 GMT 2020", "%a %b %d %T GMT %Y")

 Hope this what you're after

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Depends on what you mean by interfering, but this will parse the date into GMT

| makeresults
| eval _time=strptime("Mon Sep 28 00:00:00 GMT 2020", "%a %b %d %T %Z %Y")

and this will parse the date to your local time

| makeresults
| eval _time=strptime("Mon Sep 28 00:00:00 GMT 2020", "%a %b %d %T GMT %Y")

 Hope this what you're after

 

isoutamo
SplunkTrust
SplunkTrust

Hi

here is described those parameters. https://docs.splunk.com/Documentation/Splunk/8.0.5/SearchReference/Commontimeformatvariables
Based on your example you should try this 

eval pTime = strptime (timeField, “%a %b %d %H:%M:%S %Z %Y”)

You must take care of GMT also as it tells time zone, even it’s meaning UTC.

r. Ismo

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...