Splunk Search

Issue with strptime

sethinkbold
Engager

I am trying to convert a date / time into 24 hour format using strptime. Here's the example:
OpenedAt = 5/4/2019 9:04:46 PM

I convert it to epoch using the following statement:
eval new_time=strptime(OpenedAt,"%m/%d/%Y %H:%M:%S %p")

When I test it again, it still dosn't show in 24 hour format:
eval new_time2=strftime(new_time,"%m/%d/%Y %T")

05/04/2019 09:04:46

Labels (1)
Tags (1)
0 Karma
1 Solution

vnravikumar
Champion

Hi

Check this

| makeresults 
| eval date="5/4/2019 9:04:46 PM",new_date=strftime(strptime(date,"%d/%m/%Y %I:%M:%S %p"),"%d/%m/%Y %H:%M:%S")

View solution in original post

to4kawa
Ultra Champion
| makeresults 
| eval OpenedAt ="5/4/2019 9:04:46 PM" 
| eval new_time=strptime(OpenedAt,"%m/%d/%Y %I:%M:%S %p") 
| eval new_time2=strftime(new_time,"%m/%d/%Y %T")

see reference.
https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables

vnravikumar
Champion

Hi

Check this

| makeresults 
| eval date="5/4/2019 9:04:46 PM",new_date=strftime(strptime(date,"%d/%m/%Y %I:%M:%S %p"),"%d/%m/%Y %H:%M:%S")
Get Updates on the Splunk Community!

Cisco Catalyst Center Meets Splunk ITSI: From 'Payments Are Down' to Root Cause in ...

The Problem: When Networks and Services Don't Talk Payment systems fail at a retail location. Customers are ...

Print, Leak, Repeat: UEBA Insider Threats You Can't Ignore

Are you ready to uncover the threats hiding in plain sight? Join us for "Print, Leak, Repeat: UEBA Insider ...

New Year, New Changes for Splunk Certifications

As we embrace a new year, we’re making a small but important update to the Splunk Certification ...