Page 1 of 1

date()/time() returning incorrect time?

Posted: Mon Jan 05, 2009 10:36 pm
by Cirdan
Okay, I have this code that simply sets a cell to the current time using the time() function:

Code: Select all

function updateLastSeen($id)
{
    global $site_db;
    
    $time = time();
    
    $query = sprintf("UPDATE r_users SET last_seen='%s' WHERE id='%s' LIMIT 1",
                        $site_db->escape($time), $site_db->escape($id));
                
    $site_db->query($query);
                        
    return $time;
}
I set the value at 20:29, but the value put into mysql is 20:01, and for some reason the date will never update. It is always set to 20:01

Code: Select all

<?=date($_SESSION['site_dtformat'], $user['last_seen'])?>
site_dtformat = M jS Y H:m a
last_seen = 1231216344
output = Jan 5th 2009 20:01 pm

Re: date()/time() returning incorrect time?

Posted: Mon Jan 05, 2009 10:49 pm
by requinix
'm' in the date format string means month, not minute. You want to use 'i'.

Re: date()/time() returning incorrect time?

Posted: Mon Jan 05, 2009 10:50 pm
by Cirdan
Yea..just realized that right before I read your post. I think I need to take a break from this code :|