Save timestamp in database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Save timestamp in database (/showthread.php?tid=70607) |
Save timestamp in database - omid_student - 05-03-2018 Hi I can save current timestamp with UNIX_TIMESTAMP function in mysql example 1525352382 My project is international and for each country,i have to show time according timezone it In php i can set timezone to current country and get time from timestamp But it is important that what is mysql timezone for base? Example is it London or other? RE: Save timestamp in database - InsiteFX - 05-03-2018 Here is a Mind Blowing article on it. Today I learned about MySQL and timezones Hope that helps. RE: Save timestamp in database - omid_student - 05-03-2018 (05-03-2018, 09:00 AM)InsiteFX Wrote: Here is a Mind Blowing article on it. The best site i'v ever seen in all site Thank you And new problem is I need timestamp in database when user add data to database and show it in user's app according relate time zone I save UNIX_TIMESTAMP in database with time zone +00:00 and use output in app with different time zone Is it right? RE: Save timestamp in database - InsiteFX - 05-03-2018 Code: # user created timestamp For the timezone I found this article. How to Detect User Timezone in PHP Let me know if that works for you. RE: Save timestamp in database - omid_student - 05-03-2018 (05-03-2018, 11:12 AM)InsiteFX Wrote: In your way,output is example 2018-2-2 12:10:20 But i save unix timestamp because need convert timestamp to user timezone RE: Save timestamp in database - InsiteFX - 05-04-2018 MySQL by default will use the system time zone internally but it's possible to define a different time zone for the MySQL server globally or even per transaction. When you insert a date, it is not possible to define the time zone along with the date string in MySQL. A date like '2013-11-10 00:00' refers to a point in time since the epoch. You store it and you know what time zone your server is in. Then when you retrieve it, you can make the necessary adjustments to transform that date form the server's time zone to the client's. SEE: This MySQL Cheat Sheet MySQL Timezone Cheatsheet RE: Save timestamp in database - omid_student - 05-04-2018 (05-04-2018, 03:58 AM)InsiteFX Wrote: MySQL by default will use the system time zone internally but it's possible to define a different time zone Thank you |