Calculating PDT or PST

I am building a site for a client who lives in Seattle. He shows times for daily therapy sessions in either PDT or PST. I was going to set the global timezone of the site to the city of Los Angeles (same timezone as Seattle) so the site automatically switched during Daylight Saving time.

Is there any way you could recommend I could dynamically set the text showing as PDT or PST around the site so it switches automatically as well?

The only way I could come up with was to have a post with a PDT / PST field and have all the PDT/PST text elements looped to it. Then get the client to set it manually twice a year. Not ideal, but daylight savings doesn’t always fall on the same day each year.

This is the site:
https://darrenh43.sg-host.com/book-online/

Cheers,
Darren.

Don’t have too much experience with timezones like this. But it is possible to change the default timezone at the request level. I guess it depends on how you want to display this. If you want PST + PDT displayed this method won’t help you, but you could try to switch the PHP timezone based on a GET parameter (?tz-switch=true in this case). Let me know if that helps.

add_action("init", function() {
  if (!empty($_GET['tz-switch'])) {
      date_default_timezone_set('America/Los_Angeles');
  }
});

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.