there is a function in php to set default timezone-
date_default_timez开发者_如何学编程one_set('Asia/Calcutta');
but does this need to be called every time in the application, whenever I want to make use of date?
but does this need to be called every time in the application, whenever I want to make use of date?
If your application needs a different timezone than configured in php.ini, then yes, you need to call date_default_timezone_set
in your script. You will also need to call it if there is no timezone configured in php.ini, though if that is the case, you need to pester your host to fix it.
You can set the timezone in php.ini and then not have to worry about calling it in your script each time: http://php.net/manual/en/datetime.configuration.php
精彩评论