Splunk Search

Issue with strptime and strftime

deepak312
Explorer

I have a time input like below,

Mon Jul 13 09:30:00 PDT 2015

| eval human_readable_time= strftime(strptime(my_time, "%a %b %d %H:%M:%S %Z %Y"), "%m/%d/%y")

This doesn't return me anything. Not sure what is wrong. Any idea?
Second approach, I have tried is,

| eval human_readable_time= strftime(my_time, "%+")

marina_rovira
Contributor

HI there!

Have any of you two find a solution do this? I'm trying to get a time period for a call useing this:
eval final=(strptime(EndTime, "%a %b %d %H:%M:%S %Z%z %Y") | eval start=strptime(StartTime, "%a %b %d %H:%M:%S %Z%z %Y")

And then the rest between final-start, but I'm getting both fields empty. Any idea?

Thank you!

0 Karma

gcusello
SplunkTrust
SplunkTrust

I tried your transformation and the first one correctly works (the second one no).
could you share a log example?
I tried with the following search

index=* | head 1 | eval my_time="Mon Jul 13 09:30:00 PDT 2015" | eval human_readable_time=strftime(strptime(my_time,"%a %b %d %H:%M:%S %Z %Y"),"%m/%d/%y") | table _time human_readable_time

Bye.
Giuseppe

0 Karma
Get Updates on the Splunk Community!

Transforming Financial Data into Fraud Intelligence

Every day, banks and financial companies handle millions of transactions, logins, and customer interactions ...

How to send events & findings from AWS to Splunk using Amazon EventBridge

Amazon EventBridge is a serverless service that uses events to connect application components together, making ...

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...