Welcome Guest, Not a member yet? Register   Sign In
Manage date as UTC
#7

(This post was last modified: 01-03-2016, 12:43 PM by Gianluigi.)

(01-03-2016, 10:08 AM)skunkbad Wrote: Try adding parenthesis to num_rows:

Code:
if($query->num_rows() == 0) { return false; }

Uhm, it works..


Back to UTC, I've tried now both with local and an online server.
First without $this->db->query('SET time_zone = "00:00"');

Read data:
Retrieve mysql stored in TIMESTAMP colum "YYYY-MM-DD HH:MM:SS.000000", it show the same when I print out the input on the view. It's ok.

On write there's the issue, by PHP. Using for insert this:
PHP Code:
date'Y-m-d H:i:s'time() ) 

It uses the local datetime. IIt works as I want with this:
PHP Code:
date_default_timezone_set('UTC'); 

Above the query, or in CI index.php on the top to use it in all website/db queries.

Seems there's no chance to set it in php.ini, beacuse there are no UTC in supported list of timezones: http://www.php.net/manual/en/timezones.php

I've tried also your code, maybe I don't uderstand how to use it in single query (it gives me error). But, in any case, I need the setting in all queries. So, i think to go with the code above in index.php (if there are no specific/performance contraindications).

I only have to understand why not let me use the SQL milliseconds. I've tried to add data in MySQL with this:
PHP Code:
date'Y-m-d H:i:s'time() ) . "." substr(microtime(TRUE), -4) . "00" 

But it still save data with 000000 milliseconds after dot.


Thank you!
Reply


Messages In This Thread
Manage date as UTC - by Gianluigi - 01-02-2016, 11:40 AM
RE: Manage date as UTC - by skunkbad - 01-02-2016, 12:19 PM
RE: Manage date as UTC - by Gianluigi - 01-02-2016, 04:22 PM
RE: Manage date as UTC - by skunkbad - 01-02-2016, 05:19 PM
RE: Manage date as UTC - by Gianluigi - 01-03-2016, 04:19 AM
RE: Manage date as UTC - by skunkbad - 01-03-2016, 10:08 AM
RE: Manage date as UTC - by Gianluigi - 01-03-2016, 12:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB