Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

Help Me/Question Storing The Time Difference In Database Table

Discussion in 'PHP Programming' started by PrashantD, Feb 4, 2016.

  1. PrashantD

    Yellow Belt

    Joined:
    Dec 7, 2015
    Messages:
    132
    Ratings:
    +24 / -0
    Hi friends,

    I'm having a tough time trying to figure this out because I want to store time in an array but it's turning out to be a bit more complicated because of the way this thing is set-up. I've included the code to make it easier to understand:

    Code:
    Select All
    $result = $m->getAlliancePlayers ($this->allianceData['players_ids']); // Grabbed all player IDs that are in the alliance $this->allianceData['players'] = array(); // Created an array for players who are in that alliance while ( ($result != NULL && $result->next())) // If the result isn't NULL, grab data { $this->allianceData['players'][] = array ( // Filling in the players array with data 'id' => $result->row['id'], 'name' => $result->row['name'], 'total_people_count' => $result->row['total_people_count'], 'alliance_roles' => $result->row['alliance_roles'], 'villages_count' => $result->row['villages_count'], 'lastLoginInSeconds' => $result->row[TIMESTAMPDIFF(SECOND, 'last_login_date', NOW()] );
    If you look at lastLoginInSeconds, I'm guessing I can't do that right? because I'm also pulling 'last_login_date' from the database. Basically my goal is to be able to store the time difference of the user from the time they last logged in to the current time and store it in the above array but not sure how I would do this. Any help will be appreciated. Thanks. :)
     

Share This Page