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

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...