Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:27:54+00:00 2026-05-28T05:27:54+00:00

In PHP (since 5.2.0) I can write this code: //$t is timestamp of day

  • 0

In PHP (since 5.2.0) I can write this code:

//$t is timestamp of day I want to look at
$tz=new DateTimeZone('America/New_York');
$transition = $tz->getTransitions($t,$t);
if(!$transition || count($transition)==0)throw new Exception("Bad timezone")
$offset=$transition[0]['offset'];   //This is seconds ahead of GMT.
      //I.e. -14400 in summer, -18000 in winter.

I nearly cried with joy when I discovered this class/idiom; but is there a way to do the same thing in R? Or do I have to resort to what I used to do in PHP, which was hard-code an array of summertime start/end dates for each timezone I need to consider?

(BTW, for more on the PHP code, see: How to tell if a timezone observes daylight saving at any time of the year? )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:27:55+00:00Added an answer on May 28, 2026 at 5:27 am

    With as.POSIXct and as.POSIXlt you can get this information. For example:

    tz = 'Europe/Madrid'
    d1 <- as.POSIXct('2010-01-01 12:00:00',  tz = tz)
    as.POSIXlt(d1)$isdst ## 0 since it's not DST
    

    If you need the difference from UTC:

    d0 <- as.POSIXct(format(d1,  tz = 'UTC'),  tz = tz)
    as.numeric(d1 - d0) ## 1 hour
    

    The same for another day:

    d2 <- as.POSIXct('2010-07-01 12:00:00',  tz = tz)
    as.POSIXlt(d2)$isdst ## 1 since it is DST
    d0 <- as.POSIXct(format1(d2,  tz = 'UTC'),  tz = tz)
    as.numeric(d2 - d0) ## 2 hour
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone direct me to or write their experiences installing Apache and PHP on
When I write PHP code for websites, I don't like mixing business logic with
Since PHP is a dynamic language what's the best way of checking to see
Since PHP has no custom-class type-casting, how would I go about doing the PHP
Sessions in PHP seemed to have changed since the last time I used them,
It's been a while since I've installed PHP for Windows, but every guide I've
In a language such as (since I'm working in it now) PHP, which supports
I don't know how php.ini was configured since I don't have access to it.
I am writing a website with PHP. Since it will need to be accessed
Working on this page: http://www.karlsenner.dreamhosters.com/about.php and having trouble with the navigation in IE6. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.