Getting Data In

Converting PST to UTC

purushot1234
New Member

Hello,

I am trying to convert current PST time to UTC. I have written below code.
But when I compare with current time in UTC, there is a difference between two. They are not same.

Please let me know if I am missing anything

STRT_TIME = 01-APR-2020 20:30:21 ( Current PST time search from google)

| eval START_TIME= "01-APR-2020 20:30:21"
| eval myUTCtimeEpoch=round(strptime(START_TIME." PST","%d-%B-%Y %H:%M:%S %Z"))
| eval myUTCtime=strftime(myUTCtimeEpoch,"%d-%B-%Y %H:%M:%S %Z")
| eval current_date_utc = strftime(round(now()),"%m/%d/%Y %H:%M:%S %Z")
| table START_TIME current_date myUTCtime

Result:

STRT_TIME = 01-APR-2020 20:30:21
myUTCtime = 02-April-2020 04:30:21 UTC
current_date_utc = 04/02/2020 03:30:21 UTC

Above, I was expecting current_date_utc and myUTCtime to be same but there is 1 hour difference between them.

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

manjunathmeti
SplunkTrust
SplunkTrust

Pacific Standard Time(PST) is 8 hours behind the Coordinated Universal Time (UTC). Looking at the value of current_date_utc, it looks like your system is using Pacific Daylight Time (PDT) which is 7 hours behind UTC. You need to use PDT instead of PST in time conversion. Google PST vs PDT to understand differences.

| eval START_TIME= "01-APR-2020 20:30:21"
| eval myUTCtimeEpoch=round(strptime(START_TIME." PDT","%d-%b-%Y %H:%M:%S %Z"))
| eval myUTCtime=strftime(myUTCtimeEpoch,"%d-%B-%Y %H:%M:%S %Z")
| eval current_date_utc = strftime(round(now()),"%m/%d/%Y %H:%M:%S %Z")
| table START_TIME current_date myUTCtime

View solution in original post

0 Karma

manjunathmeti
SplunkTrust
SplunkTrust

Pacific Standard Time(PST) is 8 hours behind the Coordinated Universal Time (UTC). Looking at the value of current_date_utc, it looks like your system is using Pacific Daylight Time (PDT) which is 7 hours behind UTC. You need to use PDT instead of PST in time conversion. Google PST vs PDT to understand differences.

| eval START_TIME= "01-APR-2020 20:30:21"
| eval myUTCtimeEpoch=round(strptime(START_TIME." PDT","%d-%b-%Y %H:%M:%S %Z"))
| eval myUTCtime=strftime(myUTCtimeEpoch,"%d-%B-%Y %H:%M:%S %Z")
| eval current_date_utc = strftime(round(now()),"%m/%d/%Y %H:%M:%S %Z")
| table START_TIME current_date myUTCtime
0 Karma

purushot1234
New Member

Hi Manjunathmeti, Thank you very much for this clarification

Regards
Puru

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 ...