473,320 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem in setting timezone

Hi everyone

I want to set timezone (US/Central). It is working fine on my local computer but when I upload the code on web server It is giving me error

Fatal error: Call to undefined function: timezone_open() in

Here is the code

Expand|Select|Wrap|Line Numbers
  1. $tz1 = timezone_open("US/Central"); 
  2. $ts = date_create("2008-08-19 12:19:21", $tz1);  
  3. echo $ts->format(DATE_RFC822), "<br/>";$ts->setTimezone($tz1); 
If anyone could help me

Regards
Aug 27 '08 #1
7 2777
Dormilich
8,658 Expert Mod 8TB
what php version does the server use? timezone_open() requires PHP 5.1.0 at least.
Aug 27 '08 #2
Hi all,

I have the same error log:
Expand|Select|Wrap|Line Numbers
  1. Fatal error: Call to undefined function: timezone_open() in 
with simple script:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $t=time();
  3. echo($t . "<br />");
  4. $date = timezone_open($t);
  5. echo $date;
  6. ?>
and PHP 5.2.14 (cli) (built: Aug 27 2010 16:40:16)

Can someone give me a tip?

Best,

Biliards.
Sep 22 '10 #3
Atli
5,058 Expert 4TB
Are you 100% sure about that version number? (A 110% sure?) - I've lost count how many hours I've wasted because I assumed things like that without properly testing for it :)

That said, did you try bypassing the alias function and just using the normal OOP method?
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $d = new DateTimeZone(time());
  3. echo $d;
  4. ?>
Sep 22 '10 #4
Hi Atli,

yes, I'm sure:
Expand|Select|Wrap|Line Numbers
  1. # php -v
  2. PHP 5.2.14 (cli) (built: Aug 27 2010 16:40:16) 
  3. Copyright (c) 1997-2010 The PHP Group
  4. Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
  5.     with the ionCube PHP Loader v3.1.29, Copyright (c) 2002-2007, by ionCube Ltd.
  6.  
I try your script and I obtain this error log
Expand|Select|Wrap|Line Numbers
  1. PHP Fatal error:  Class 'DateTimeZone' not found
I don't understand why
Sep 23 '10 #5
Atli
5,058 Expert 4TB
That's really odd. According to the manual entry for that class it is supposed to be built into the PHP core since 5.2.0. Could it be that there is something special about your build? How did you install it?

Also, looking at this more closely, you are not using the class as it should be used. The constructor takes a timezone name, not a timestamp. That is, you should pass it a string like: "GMT", "UTC", or even something like: "Iceland" or "America/New_York".
Sep 23 '10 #6
Markus
6,050 Expert 4TB
Are you using the CLI PHP binary to test this, or are you testing through your webserver? Many times have we seen people give us the version of their CLI PHP binary, assuming it to be the same as the binary used by their webserver (it is typically not).
Sep 23 '10 #7
I'm sorry if I used the class as it should be used.
Now, before to reply to thred, I used other Centos5 server with PHP4 and I used these command-line:
Expand|Select|Wrap|Line Numbers
  1. # yum update
  2. # php -v
  3. PHP 5.1.6 (cli) (built: Mar 31 2010 02:44:37) 
  4. Copyright (c) 1997-2006 The PHP Group
  5. Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
  6. # more test.php
  7. <?php
  8. $date = timezone_open('UTC');
  9. echo $date;
  10. ?>
  11. # php test.php
  12. PHP Fatal error:  Call to undefined function timezone_open() in ... on line 2
So that I used two guides:
* wiki.centos.org to update PHP from 5.1.6 to 5.2.10 but I had again the error log
* jasonlitka.com to update PHP from 5.2.10 to 5.2.14 but I had again the error log

Update from 5.1.6 to 5.2.10 was completed only after I erased php-sqlite2 (yum erase php-sqlite2).
Sep 24 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Google Mike | last post by:
I guess I'm confused by the whole timezone thing and I don't want to write a web app that gets this stuff wrong. I don't know how timezones work exactly -- is it just hours +/- on GMT or are there...
4
by: Anony Mous | last post by:
Hi, Is there a function that would allow me to set the local time while the server is running? I can't seem to find anything on this... Thanks, Peter ---------------------------(end of...
6
by: Varangian | last post by:
Hello there, I'm having a problem with Utcnow property. I'm checking the Utcnow for IsDayLightSaving() if true or false. I'm setting the timezone to GMT time London etc and during summer when...
2
by: Ken Varn | last post by:
I have a managed C++ method that I call from ASP.NET to set the time zone on the local box. I call SetTimeZoneInformation, which does not return an error, but the time zone remains unchanged. I...
7
by: Ramon | last post by:
Hello, when I send an email using the mail() function, I get a Runtime Notice: date() : It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ...
0
by: jrhastings | last post by:
I know there are many threads on this topic but I haven't yet found an answer to this question. I'd like to map from a utc to a local time in an arbitrary timezone (not necessary the default local...
1
by: JJ | last post by:
I'm having problems trying to publish an ASP.NET project from VS2005 and was hoping to get some pointers in the right direction. The project works fine from my development system using the...
0
by: helloitsme | last post by:
Hello All! I know there already exists a thread with this topic by Mike! But my problem did not get solved with that.... I have a working code in VB6 that can set the selected timezone for the...
3
by: mac11 | last post by:
I have an app that runs under Linux (centos and LFS flavors) and I'm having problems with reading the correct time after I change the timezone (by moving the link at /etc/localtime to point to the...
7
by: Looch | last post by:
All, I'm using a WinForm app that calls methods on a remotable object. The app server hosting the object is in New York. Using the same exact application, a Sql Server 2005 datetime column's...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.