Getting Data In

Why are relative_time() and strptime() using different time zones?

matstap
Communicator

I ran this query:

| makeresults 
| eval creationdate = "2018-11-15 20:00:00.000000000"
| eval epoch=relative_time(now(), "@h"), epoch2=strptime(creationdate, "%Y-%m-%d %H:%M:%S.%N")

I ran it at a time when epoch and epoch2 should return the same value. However, epoch and epoch2 are 8 hours off from each other, with epoch being the correct value.

What can I do to troubleshoot this?

0 Karma
1 Solution

FrankVl
Ultra Champion

I think that's because now() returns an epoch timestamp in UTC, while the string you have crafted is probably your local time? Converting that to an epoch value without telling strptime what timezone it should use, results in strptime using the splunk server's timezone to convert that, which probably was different from your personal local timezone?

View solution in original post

FrankVl
Ultra Champion

I think that's because now() returns an epoch timestamp in UTC, while the string you have crafted is probably your local time? Converting that to an epoch value without telling strptime what timezone it should use, results in strptime using the splunk server's timezone to convert that, which probably was different from your personal local timezone?

matstap
Communicator

That's what was happening. I appended the correct time zone into the date when inputting into the strptime and it works.

0 Karma

Richfez
SplunkTrust
SplunkTrust

For clarification - what exact version of Splunk are you running this on?

0 Karma

matstap
Communicator

@rich7177 Version 6.6.3

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...