Splunk Search

how to convert UTC time into mmddyy format

mtidke
Observer

Hi,

 

how to convert UTC time into mmddyy format.

I tried this query for search

| makeresults
| eval time
| eval readable_time = strftime(strptime(tostring(time/1000), "%s"), "%m%d%y")
| table time, readable_time

The time format is time1717690912746

 

Thank you 

Labels (3)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

I do not get the question.  Except that you need to put that value into eval, the search does give you 060624.  Isn't this what you are looking for?  What is the question?

 

| makeresults
| eval time=1717690912746
| eval readable_time = strftime(strptime(tostring(time/1000), "%s"), "%m%d%y")
| table time, readable_time

 

This is what I get

timereadable_time
1717690912746060624

Screen Shot 2024-06-06 at 10.04.06 PM.png

0 Karma

antoniolamonica
Explorer

Unsure what format "time" is in for you.

You could try converting "time" into unix time (assuming it is populating differently from "_time"), and then converting it back into readable_time:

| eval time=
(time, "%H:%M") (this may vary on its current format)
| eval readable_time = strftime(_time, "%m/%d/%Y")

be sure not  to confuse "time" and "_time"
_time is by default in unix time.

https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions

If this helped, karma is appreciated.

Tags (1)
0 Karma

deepakc
Builder
| makeresults
| eval time=1717690912746
| eval readable_time = strftime(time,"%m/%d/%y %H:%M:%S")
| table time, readable_time
0 Karma

mtidke
Observer

I tried this but got an error

Error in 'EvalCommand': Failed to parse the provided arguments. Usage: eval dest_key = expression.
The search job has failed due to an error. You may be able view the job in the

0 Karma
Get Updates on the Splunk Community!

Splunk App for Anomaly Detection End of Life Announcment

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...