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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...