It seems to be a very difficult task to set time zone based on user's current location in PHP.
I am finding it difficult to implement time zone dynamically in PHP, I am using codeigniter framework.
I found a git repository here https://github.com/tamaspap/timezones , but not able to integrate it with my codeigniter project.
You can set timezone just using date_default_timezone_set('timezone_name');
.The date_default_timezone_set()
function sets the default timezone used by all date/time functions in the script.
For example :
date_default_timezone_set('America/Los_Angeles');
Sets timezone for America/Los_Angeles
.
Placing this date_default_timezone_set('Asia/Kolkata'); on config.php above base url also works http://php.net/manual/en/timezones.php
application/config.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
date_default_timezone_set('Asia/Kolkata');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.