Splunk Search

Convert TimeFormat

hartfoml
Motivator

I have an event field called `LastBootUpTime=20120119121719.125000-360'

I am trying to convert this to a more readable format by using this convert command

| convert timeformat="%m-%d-%Y %H:%M:%S" ctime(LastBootUpTime) AS BootTime

this is not working. What am I missing??

Tags (2)
0 Karma
1 Solution

bojanz
Communicator

If I'm not wrong, convert needs epoch time for ctime().
So use strptime to convert to epoch time this first:

| eval temp=strptime(LastBootUpTime,"%Y%m%d%H%M%S") | convert timeformat="%m-%d-%Y %H:%M:%S" ctime(temp) AS BootTime

This will return BootTime in a human readable format, as specified in the timeformat parameter.

View solution in original post

bojanz
Communicator

If I'm not wrong, convert needs epoch time for ctime().
So use strptime to convert to epoch time this first:

| eval temp=strptime(LastBootUpTime,"%Y%m%d%H%M%S") | convert timeformat="%m-%d-%Y %H:%M:%S" ctime(temp) AS BootTime

This will return BootTime in a human readable format, as specified in the timeformat parameter.

hartfoml
Motivator

That was the answer... howd you get so smart 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...