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!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

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