0

I have fields in a table that are being constantly updated with the current time (each second). First, the controller calls a function to create the record in the database

public function saveEntry($theuser='')
    {   
        $data = array(
           'theuser' => $theuser ,
           'dateentered' => date('Y-m-d') , //date('d-m-Y H:i:s') ,
           'gname' => date('d-m-Y H:i:s') ,
                   'ldate' => date('Y-m-d'),
                   'ltime' => date('H:i:s'),
                   'ldatetime' => date('Y-m-d H:i:s')
                    );      
        $this->db->insert('onlineusers', $data);        
    }

Then, after the view is called, an ajax function keeps updating the time on the database.
The problem is that when ajax updates the database (with a simple .php update page), the time is less 10 or so minuts than when Codeigniter's function created the record. The difference bettwen CodeIgniter and a simple .php file is, always, more or less 10 minuts
What could I be doing wrong? Is there a way to sincronize the two? Or some other way possible to solve the problem?

My thanks in advanced

3
Contributors
2
Replies
19
Views
3 Years
Discussion Span
Last Post by Tpojka
0

Hi,

It should not depend on CodeIgniter, this can relate to the system in which PHP is executed: in the case is not synchronized. Have you tried to display the date time from a CodeIgniter view? If you can, compare it with a simple script, for example:

echo date('d-m-Y H:i:s');

It could be that some insert queries are failing, in this case it can be helpful to see the ajax call and the Controller.

0

In the same time when function above is executed, you can execute query on you DB table
SELECT CURTIME()
too and compare those two results.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.