Splunk Dev

Time_format_change_procedure

abid91
Engager

Hi Guys,
I am trying to create a use-case as " date when any single user was created in AD" it's done but I need to change time format to readable format, right now it coming like this "20170905133223.0Z" how can I convert it to as " 05-September-2017" I tried with eval command as follows but no effect in results.

search:| ldapsearch domain=default search="(objectClass=user)" | table displayName,whenCreated |eval epochtime=strptime(whenCreated, "%Y %m %d %H:%M:%S") | eval desired_time=strftime(epochtime, "%d/%m/%Y")
result: ABC|20170905133223.0Z
desired result: ABC|05-September-2017

Tags (1)
0 Karma
1 Solution

inventsekar
SplunkTrust
SplunkTrust

Please check -
search:| ldapsearch domain=default search="(objectClass=user)" |eval epochtime=strptime(whenCreated, "%Y%m%d%H%M%S.%1N%Z") | eval desired_time=strftime(epochtime, "%d/%m/%Y") | table displayName whenCreated desired_time

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !

View solution in original post

inventsekar
SplunkTrust
SplunkTrust

Please check -
search:| ldapsearch domain=default search="(objectClass=user)" |eval epochtime=strptime(whenCreated, "%Y%m%d%H%M%S.%1N%Z") | eval desired_time=strftime(epochtime, "%d/%m/%Y") | table displayName whenCreated desired_time

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !

abid91
Engager

Yes! it's working thank you

0 Karma

gcusello
SplunkTrust
SplunkTrust

HI abid91,
try something like this

| ldapsearch domain=default search="(objectClass=user)" 
| eval whenCreated=strftime(strptime(whenCreated, "%Y %m %d %H:%M:%S"), "%d/%m/%Y")
| table displayName,whenCreated 

Check the original time format of whenCreated
Bye.
Giuseppe

0 Karma

abid91
Engager

its showing blank values in whenCreated filed.

0 Karma
Get Updates on the Splunk Community!

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2025 SplunkTrust is officially open! If you ...

Splunk Answers Content Calendar, June Edition II

Get ready to dive into Splunk Dashboard panels this week! We'll be tackling common questions around ...

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

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