Splunk Search

How to covert GMT Time(0-12:00) to PST time.

rajhemant26
New Member

My result is giving me the output for GMT time for the given time what I have defined.

Tags (1)
0 Karma

whrg
Motivator

Hello @rajhemant26,

If your events have an incorrect time zone, then I suggest you set the correct zone at index time using TIME_FORMAT or TZ in props.conf.

If your events have the correct time zone and you want to display them in your local time zone, then change the time zone in the user settings. (Click on your username at the top and then click on "Preferences".)

If you want to shift the time of your events at search time (I believe this is want you want), then do this:

index=dcsdjc ... | eval _time=_time-7*60*60 | ...

This will substract 7 hours from _time. It works because _time is represented as Unix epoch time.

However, it will not update the date_wday and date_hour fields.

So do this:

index=dcsdjc ... | eval _time=_time-7*60*60 | eval wday=strftime(_time,"%a") | eval hour=strftime(_time,"%H") | search hour>=0 ...
0 Karma

rajhemant26
New Member

@whrg thankyou so much for your help. but this is giving me for the entire week,
but I want to see the output only for weekdays ( Monday to Friday)

0 Karma

whrg
Motivator

Add this to the search above:

| search hour>=0 hour<=12 wday IN (Mon,Tue,Wed,Thu,Fri)

Or for numerical week days ("%w" instead of "%a"):

index=dcsdjc ... | eval _time=_time-7*60*60 | eval wday=strftime(_time,"%w") | eval hour=strftime(_time,"%H") | search hour>=0 hour<=12 wday>=1 wday<=5

Check out the documentation on Date and time format variables.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...