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!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...