Getting Data In

How to change the time field value /date(1548574937484) to human readable format ?

balu1211
Path Finder
 
Labels (1)
Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @balu1211,

you need two steps:

  • extract the date in epochtime format
  • convert date from epochtime to Human Readable.

something like this:

| makeresults 
| eval WhenOccurred="/date(1548574937484)"
| rex field=WhenOccurred "(?<date_epoch>\d+)"
| eval date=strftime(date_epoch/1000,"%Y-%m-%d %H:%M:%S")
| table date_epoch date

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @balu1211,

you have to use the strftime option in the eval command (https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions#strftime.28...), something like this:

<your_search>
| eval date=strftime(date,"%Y-%m-%d %H:%M:%S")

Ciao.

Giuseppe

0 Karma

balu1211
Path Finder

Hi @gcusello ,

My usecase is like want to convert the WhenOccurred field format to readable format.

Thanks 

IMG_20221103_201843.jpg

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @balu1211,

you need two steps:

  • extract the date in epochtime format
  • convert date from epochtime to Human Readable.

something like this:

| makeresults 
| eval WhenOccurred="/date(1548574937484)"
| rex field=WhenOccurred "(?<date_epoch>\d+)"
| eval date=strftime(date_epoch/1000,"%Y-%m-%d %H:%M:%S")
| table date_epoch date

Ciao.

Giuseppe

balu1211
Path Finder

Hi @gcusello,

 

eval WhenOccurred="/date(1548574937484)"

What i have to mention in the  

| eval  WhenOccurred="/date (   ) "   ? 

Default it is taking 1548574937484 for all  values 

 

Thanks.....

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @balu1211,

first two rows are only for my test, your search is:

<your_search>
| rex field=WhenOccurred "(?<date_epoch>\d+)"
| eval date=strftime(date_epoch/1000,"%Y-%m-%d %H:%M:%S")
| table date_epoch date

Ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated 😉

Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...