Top Web2

Javascript , CSS , XHTML , Web 2 ,PHP and more

Subscribe to Top Web2

setting default timezone in php

Posted by Net Code On April - 7 - 2009

there is many situations that you need to set the default timezone before you use date or time function such as date()
for example if your script user not in the country that you have the server or hosting on and you want to record lastlogin time , yes you are in trouble

there is many ways to do that
you can modify the .htaccess


php_value date.timezone America/New_York

but notice you must have php5 enabled in the server so you can use this

another one that i prefer is from your script not from htaccess
you can add this line in your php script before you use any date/time functions


date_default_timezone_set('America/New_York');

so you can modify default time zone in php use htaccess or php funciton date_default_timezone_set

enjoy :)

About the Author

One Response to “setting default timezone in php”

  1. khemso says:

    thanks it did help me in the project i am currently working on :P

Leave a Reply

About Us

Hi, welcome to web2 blog . here you will find useful information about web2 , xhtml , css , css3 , html5 , javascript , jquery and much more. Explore the site and enjoy your stay and remember to comeback with your friends.

Flickr

flickrRSS probably needs to be setup