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!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

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