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

Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...