Sahithi Mamidi
Sahithi Mamidi

Reputation: 53

Splunk convert Wed Sep 23 08:00:00 PDT 2020 to _time and epoch time in splunk

Splunk convert Wed Sep 23 08:00:00 PDT 2020 to _time and epoch time in splunk . What is the splunk query to convert java date format to yyyy-MM-dd

Upvotes: 0

Views: 3012

Answers (2)

RichG
RichG

Reputation: 9916

To convert time strings from one format to another you must strptime() convert to epoch form and then use strftime() to convert to the desired result format.

... | eval newTS=strftime(strptime("Wed Sep 23 08:00:00 PDT 2020", "%a %b %d %H:%M:%:S %Z %Y"), "%Y-%m-%d")

Upvotes: 0

Simon Duff
Simon Duff

Reputation: 2651

From https://docs.splunk.com/Documentation/Splunk/8.0.6/SearchReference/DateandTimeFunctions#strptime.28X.2CY.29

| eval date_unix_timestamp=strptime(date, "%Y-%m-%d")

Upvotes: 1

Related Questions