Splunk Search

Convert date and time bunched together to a readable date

splunkthat
Engager

In my splunk search for getting the date of Nessus plugins feed version used in a scan I get the number returned in the orginal format used of year-month-date-time (for example November 7th 2023 at 1200 would display as 202311071200) that I would like to convert into a readable format that I can then manipluate in splunk such as if i want to get the epoch time. How would I go about doing this?

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use the strptime function to convert text timestamps into epoch format.  Then use strftime to convert epoch timestamps into human-readable form.

| eval epochTime=strptime(plugin_date, "%Y%m%d%H%M")
| eval humanTime=strftime(epochTime, "%Y-%m-%d %H:%M")

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Use the strptime function to convert text timestamps into epoch format.  Then use strftime to convert epoch timestamps into human-readable form.

| eval epochTime=strptime(plugin_date, "%Y%m%d%H%M")
| eval humanTime=strftime(epochTime, "%Y-%m-%d %H:%M")

 

---
If this reply helps you, Karma would be appreciated.
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...