Getting Data In

How to convert Epoch to UTC timestamp?

snehasal
Explorer

Hi

I am setting a time token "WFDate_tok_display1" which has timestamp value from the user click. The report shows Date as 18th July. however when I extract it using strftime(), it shows the time in PST (my local time) whereas the original time showed in Splunk events (i.e _time) is in UTC.

<drilldown>
            <set token="WFDate_tok_display">$click.value$</set>
            <eval token="WFDate_tok_display1">strftime(WFDate_tok_display,"%m/%d/%y")</eval>
</drilldown>

<panel>
        <title>Runtime for on $WFDate_tok_display2$ 
          between $WFDate_tok$ and $WFDate_tok1$ </title>
</panel>

Please help in converting this timestamp to UTC.

Thanks,
Sneha Salvi

0 Karma

splunkyj
Path Finder

Great tip DalJeanis

0 Karma

DalJeanis
Legend

Splunk defaults to presenting in your own time. You can change your user settings to where everything appears in UTC, or you can format the time explicitly into UTC by using %Z.

strftime(WFDate_tok_display,"%m/%d/%y %Z")

If that doesn't work (and it should) then here's a link to where a guy posted a macro to force into UTC - https://answers.splunk.com/answers/41585/display-time-in-utc.html


By the way, you will save yourself hordes of grief if you get into the habit of presenting dates like this -

strftime(WFDate_tok_display,"%Y-%m-%d %Z")

If you do that, then you will always be able to sort by the formatted date, or subset the year or month without further calculation.

Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...