Splunk Search

Convert UTC time to EPOCH

SK2007
Loves-to-Learn Lots

Hi Team,

 

I am finding a way to convert UTC to EPOCH   and vice versa for my search query

 

Sample is here -> date2021-09-04 08:25:56 UTC

0 Karma

PickleRick
SplunkTrust
SplunkTrust

strptime() and strftime() are functions you use to convert between string representation and unix timestamp. But remember that instead of creating a field with string representation of a date you can do a fieldformat, so that internally splunk manipulates the timestamp as integer (it's much easier to do date arithmetics this eay) and only presents the results rendered to given string format.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
0 Karma

SK2007
Loves-to-Learn Lots

I am trying this way,

 

| makeresults
| eval time ="2021-09-04 08:25:56 UTC"
| eval time_ephoc= strptime(time , "%Y-%m-%d %H:%M:%S")| eval timebackUTC=strftime(time_ephoc,"%Y-%m-%d %H:%M:%S UTC")

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

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

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...