outputsPHP Code:$date = time();
echo date("j F Y - g:i a", $date);
22 April 2012 - 2:27 pm
when it should output
22 April 2012 - 12:27 am
I'm running this on WAMP on my home computer. Any help?
outputsPHP Code:$date = time();
echo date("j F Y - g:i a", $date);
22 April 2012 - 2:27 pm
when it should output
22 April 2012 - 12:27 am
I'm running this on WAMP on my home computer. Any help?
Is this an example of the problem or a specific problem for the date() function?
It sounds to me like either your PHP configuration either is set to the wrong timezone, or your default active timezone in PHP is wrong.
Those sound similar, but they're not. PHP knows what time it is. But that might be wrong (off by 2 hours). And/or when you use date() it uses whatever timezone setting is active, usually determined by a default timezone, relative of course to PHP's base time setting. In other words, does PHP not know the right time, or does PHP just think you want to output time for somewhere else?
Of course it could also be a server-level problem. Maybe check your logs to see if the logs also have weird times on them.
You can try to figure out the details and fix them, or you can just set another timezone during runtime (or via .htaccess, or php.ini).
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
This is an actuall problem I'm having. I'll have a go at what you suggested and get back to you.
My first sentence wasn't clear-- I was asking whether you were using date() to demonstrate the problem (with the server in general) or if this problem was specific (and limited to) the date() function.
But that's fine-- post back when you know more and I'll see if I can think of anything. Unfortunately with something like this, it ends up often just being a lot of trial and error until you eventually find the source of the problem.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
I believe it is a problem with time() in general not just date().
What happens when you set the timezone with the following at the top of your script?
You could also add the same thing to your php.ini file. It would look like the following though:Code:date_default_timezone_set('America/Chicago');
If you are making this change to your php.ini file the changes may not take place right away depending on your hosting service. I use godaddy and in order for the changes to take place immediately I go to the godaddy website, access my hosting service and select end system processes. You might not have a godaddy hosting account, but a number of people do. If you need more details with how to do what I just described let me know and I can give a more detailed answer.Code:date.timezone = "America/Chicago"
I might be totally barking up the wrong tree with this post though.
To choose the lesser of two evils is still to choose evil. My personal site
Why Chicago? keyboard1333's location puts him in the Mariana Trench. I suppose that's some sort of reference to something else though. Where are you really? That's where you should be setting your timezone for. See:
http://www.php.net/manual/en/timezones.php
for the list of supported zones.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Bookmarks