CodeIgniter Forums
How save timestamp according to Asia timezone - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: How save timestamp according to Asia timezone (/thread-72813.html)



How save timestamp according to Asia timezone - omid_student - 02-14-2019

Hi
I receive timestamp base of UTC and save it into database
Now i need report all data example between 2:30 to 14:43
And i am Tehran with GMT +3:50
Can i save timestamp base of Asia/Tehran timezone or i can only get their base of my favorite timezone?
Can i set timezone to Asia/Tehran on mysql when i use SELECT command?
Thanks


RE: How save timestamp according to Asia timezone - KoRsar4eg - 02-14-2019

(02-14-2019, 01:20 PM)omid_student Wrote: Hi
I receive timestamp base of UTC and save it into database
Now i need report all data example between 2:30 to 14:43
And i am Tehran with GMT +3:50
Can i save timestamp base of Asia/Tehran timezone or i can only get their base of my favorite timezone?
Can i set timezone to Asia/Tehran on mysql when i use SELECT command?
Thanks

Hi, not sure is that what are you asking, but you can use mysql date_add and date_sub functions. 

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-sub


RE: How save timestamp according to Asia timezone - rmcdahal - 02-14-2019

In CI4 there is options for timezone setting on
public $appTimezone = 'America/Chicago';
This may help,
In CI3 in application/config.php
date_default_timezone_set('America/Chicago');


RE: How save timestamp according to Asia timezone - omid_student - 02-15-2019

(02-14-2019, 03:02 PM)KoRsar4eg Wrote:
(02-14-2019, 01:20 PM)omid_student Wrote: Hi
I receive timestamp base of UTC and save it into database
Now i need report all data example between 2:30 to 14:43
And i am Tehran with GMT +3:50
Can i save timestamp base of Asia/Tehran timezone or i can only get their base of my favorite timezone?
Can i set timezone to Asia/Tehran on mysql when i use SELECT command?
Thanks

Hi, not sure is that what are you asking, but you can use mysql date_add and date_sub functions. 

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-sub

Hi
I need set timezone in mysql and execute query $this->db->where("TIME_FORMAT(FROM_UNIXTIME(time),'%H:%i') >=", $from_time);

Can i define timezone in FROM_UNIXTIME function?


RE: How save timestamp according to Asia timezone - omid_student - 02-15-2019

(02-14-2019, 08:51 PM)rmcdahal Wrote: In CI4 there is options for timezone setting on
public $appTimezone = 'America/Chicago';
This may help,
In CI3 in application/config.php
date_default_timezone_set('America/Chicago');

Thank you but i need change timezone in mysql before execute query


RE: How save timestamp according to Asia timezone - omid_student - 02-16-2019

Finally i used CONVERT_TZ function in MySql


RE: How save timestamp according to Asia timezone - omid_student - 02-16-2019

Finally i used CONVERT_TZ function in MySql