Getting Data In

How convert time which has time and milliseconds to %Y-%m-%d %H:%M:%S?

power12
Communicator

How to I convert the following time to 2023-05-18 08:11:52
2023-05-18T08:11:52.000-07:00  

0 Karma

yeahnah
Motivator

Hi @power12 

Here are some examples of how to do it...

 

| makeresults
| eval mytime="2023-05-18T08:11:52.000-07:00"
      ,mytime_epoch=strptime(mytime, "%FT%T.%3N")  ``` convert to epoch seconds - ignore the timezone unless you want to account for it ```
      ,mytime_reformated=strftime(mytime_epoch, "%F %T")  ``` format time ```
      ,mytime_nested=strftime(strptime(mytime, "%FT%T.%3N"), "%F %T")  ``` can nest the time functions too ```
      ,mytime_replace=rtrim(replace(mytime, "(T|\..*)", " "))   ``` OR string manipulation would work in this case too ```

 

 Hope it helps

0 Karma
Get Updates on the Splunk Community!

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Community Feedback

We Want to Hear from You! Share Your Feedback on the Splunk Community   The Splunk Community is built for you ...

Manual Instrumentation with Splunk Observability Cloud: Implementing the ...

In our observability journey so far, we've built comprehensive instrumentation for our Worms in Space ...