Getting Data In

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


How to I convert the following time to 2023-05-18 08:11:52

Labels (1)
0 Karma


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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...