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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:23:42+00:00 2026-05-24T01:23:42+00:00

I suddenly get the error message Fatal error: Call to a member function setTimezone()

  • 0

I suddenly get the error message Fatal error: Call to a member function setTimezone() on a non-object after adding some new lines of code:

first of all, i used DateTime to switch between different timeformats to calculate DST, etc.

I used the following code [Code Block 1]

foreach ($result as $k=>$v)
    {$timestamp=DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z', $k,new DateTimeZone("UTC"));    //take current date from $k as new DateTile Object
         $timestamp->setTimezone(new DateTimeZone('Europe/Berlin'));   //convert timezone
         $date[]=$timestamp->format('Y-m-d H:i:s');   // "export" the date to date-array
         }

This code works well, until now:

I added 20 code lines above an other DateTime function [Code Block 2]:

$ts=new DateTime("@".round($_GET['startdate']/1000));
$startdate=$ts->format('Y-m-d\TH:i:s.u\Z');

After I added these 2 lines, all the time i get the error: Fatal error: Call to a member function setTimezone()for this line:$timestamp->setTimezone(new DateTimeZone('Europe/Berlin'));

…but i can’t see an relation / connection between these to code parts?!

What’s happened here?

Thank you, for any idea.

//Update: as you can see at the comments, i’m using PHP 5.3.6
again: the code block 1 works, if i remove the code block 2

  • 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-24T01:23:43+00:00Added an answer on May 24, 2026 at 1:23 am

    Looks like not all of array keys of $result is valid date strings. The DateTime class returns a new DateTime instance or FALSE on failure. And when $k is not valid, $timestamp is false, which is not an object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday I testet a lot on my device. Suddenly I get this error message
i get suddenly an error message, that 3 dependencies are missing: gwt-user.jar, gwt-dev.jar and
After years of working OK, I'm suddenly getting this message when trying to start
I'm suddenly back to WinForms, after years of web development, and am having trouble
While working on an existing project I suddenly got the following error when trying
I upgraded to Ubuntu Intrepid Ibex yesterday and suddenly some of the Perl modules
I'm doing some changes on my routes, and suddenly the following is appearing in
Our Test DB is suddenly missing rows. We want them back. Is there a
Visual Studio 2008 will suddenly quit when I'm manipulating the WebBrowser control in my
One of our weblogic 8.1s has suddenly started logging giant amounts of logs and

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.