PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 31, 2022

[FIXED] How to get timezone hour offset and account for DST with PEAR::Date?

 August 31, 2022     dst, pear, php, timezone     No comments   

Issue

I am trying to get the offset hours from UTC, given a summer date. My system time is set to America/Los_Angeles.

I have the following:

require_once("Date.php");

$dateTZ = new Date_TimeZone('America/Los_Angeles');

echo $dateTZ->getOffset(new Date('2009-07-01 12:00:00'))/1000/60/60;

This prints '-8'; shouldn't it show '-7'?

echo $dateTZ->getOffset(new Date())/1000/60/60;

also prints '-8'.

What am I doing wrong?


Solution

Does Date::inDaylightTime() help you? Date::getTZOffset claims to include daylight savings offset.



Answered By - cletus
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing