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 6972375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:57:35+00:00 2026-05-27T16:57:35+00:00

I am trying to make a webpage and have the next three events on

  • 0

I am trying to make a webpage and have the next three events on a Google Calendar show up on the home page. I have been using this PHP (http://james.cridland.net/code/google-calendar.html) to access my XML feed and format it into HTML.

The problem I’m having is that for some reason a new day starts at 11am. For example if my Google Calendar has an event from 10am on the 20th of December that lasts an hour, my PHP output will show an event that starts at 10am on the 20th which ends at 11am on the 21st. Otherwise it is working fine.

I have set my time to local (New Zealand) time on my Google Calendar account, and in PHP using date_default_timezone_set("Pacific/Auckland");

The horrible line that calculates the finish date is

$gCalDateEnd = date($dateformat, strtotime($ns_gd->when->attributes()->endTime)+date("Z",strtotime($ns_gd->when->attributes()->endTime)));

where $dateformat is a string with the date format.

The Google Calendar XML gives a start and finish time of

2011-12-22T10:00:00.000+13:00
2011-12-23T11:00:00.000+13:00

respectively, and the PHP is calculating a timeframe of 10.00am 22 December 2011 to 2.00pm 23 December 2011.

Whats going on?!?!

  • 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-27T16:57:36+00:00Added an answer on May 27, 2026 at 4:57 pm

    This line is indeed horrible:

    $gCalDateEnd = date($dateformat, strtotime($ns_gd->when->attributes()->endTime)+
        date("Z",strtotime($ns_gd->when->attributes()->endTime)));
    

    strtotime can handle this type of ISO 8601 dates just fine. This code-fragment is probably written under the assumption that strtotime dismisses the timezone and returns the datetime in UTC and therefore the timezone “correction” needs to be calculated manually – that’s what the +date("Z", ...) stands for (with “Z” the second parameter – the timestamp – is actually ignored).

    So in your example 13 hours are added to your dates. And 10:00 + 13:00 = 23:00 (11 pm) which is still on the same day, but 11:00 + 13:00 = 24:00 (12 am) which is actually 00:00 on a new day.

    So the correct way to convert the date is:

    $gCalDateEnd = date($dateformat, strtotime($ns_gd->when->attributes()->endTime));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an adaptable Web page where I have some circles on
I'm trying to make a form to login users into my webpage using mysql
I'm trying to make a password field for a webpage. So far I have:
No, I'm not trying to make an annoying popup. I have a simple webpage
Me and my friend were trying to make a webpage in C#. This webpage
Im trying to make this image fade into the one below it using a
I have been trying to make a DIV box appear in front of the
I am trying to make a user search bar on my webpage using ajax.
ok I have been working on this webpage for a week now and have
I am trying to make a webpage with Ajax. Example: I create a Perl/CGU

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.