date()/time() returning incorrect time?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cirdan
Forum Contributor
Posts: 144
Joined: Sat Nov 01, 2008 3:20 pm

date()/time() returning incorrect time?

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

'm' in the date format string means month, not minute. You want to use 'i'.
Cirdan
Forum Contributor
Posts: 144
Joined: Sat Nov 01, 2008 3:20 pm

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

Post by Cirdan »

Yea..just realized that right before I read your post. I think I need to take a break from this code :|
Post Reply