Splunk Search

Can you help me convert a field value extracted by a rex command to another date time format?

ameyapatil29
Explorer

Hello Community,

I have certain field values extracted by using rex command. The timestamp format of the field value is in ISO 8601.
For example -

lgk":"2018-09-24T04:41:54Z"

I need to convert it in the following format

%m-%d-%Y %H:%M:%S %p

I tried using strftime but that doesn't work. Gives blank results. Can somebody please help me with some pointers?

Thanks,
-Ameya

0 Karma

ppablo
Retired

Hi @ameyapatil29

Glad you got an answer by @493669 below. I noticed you upvoted his answer, but didn't accept it. If it solved your question, please don't forget to resolve the post by clicking "Accept" directly below his answer.

Thanks!

0 Karma

493669
Super Champion

Try this run anywhere search:

|makeresults|eval t="2018-09-24T04:41:54Z"|eval b=strftime(strptime(t,"%Y-%m-%dT%H:%M:%SZ"),"%m-%d-%Y %H:%M:%S %p")
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In January, the Splunk Threat Research Team had one release of new security content via the Splunk ES Content ...

Expert Tips from Splunk Professional Services, Ensuring Compliance, and More New ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Observability Release Update: AI Assistant, AppD + Observability Cloud Integrations & ...

This month’s releases across the Splunk Observability portfolio deliver earlier detection and faster ...