Page 1 of 1
Date not adjusting for timezones
Posted: Sat Mar 28, 2009 8:35 am
by cone13cone
I have this bit of code on one of my pages, it works although it echos back the time of the timezone that the server is on, whats the easiest way to adjust for my timezone with is three hours ahead of this time? WST -> EST
Code: Select all
<?php echo date('l jS \of F Y h:i:s A'); ?>
Thanks, John
Re: Date not adjusting for timezones
Posted: Sat Mar 28, 2009 9:51 am
by Darkzaelus
Code: Select all
<?php echo date('l jS \of F Y h:i:s A', time()+180); ?>
Darkzaelus
Re: Date not adjusting for timezones
Posted: Sat Mar 28, 2009 9:59 am
by JasonDFR
I was going to say that calling date_default_timezone_set() in your script is the easiest way, but maybe not the best, but before I finished writing this, I decided that all of these options are pretty easy.
You can use: php_value date.timezone America/New_York in a .htaccess file.
Some hosts will parse php.ini files when they are inside the web root ( public_html or www ) usually. I'm not sure if this works for files contained in subdirectories.
If your site uses a common config file included in all pages, you can call date_default_timezone_set() in it.
Re: Date not adjusting for timezones
Posted: Sat Mar 28, 2009 10:07 am
by JasonDFR
Darkzaelus wrote:Code: Select all
<?php echo date('l jS \of F Y h:i:s A', time()+180); ?>
Darkzaelus
The above adds 3 minutes to the server time.