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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...