I always have troubles with times and dates when transferring from mySQL to PHP, but I thought I'd sit down and nut it out.
I feel like I'm so close ... but no dice.
Ok, so I'm writing the current date/time to a DATETIME field in the db with
Code: Select all
putenv('TZ=Etc/GMT');
$db_time = date('YmdHis');
$sql = "UPDATE `tbl_admin_user` SET `last_log` = '$db_time' WHERE `U_PK` = '$u_id '";All good at this point, the database shows the same value of $db_time.
I pull the value back with:
Code: Select all
$sql = "SELECT `U_PK` , `username` , `auth_level`, `last_log`, UNIX_TIMESTAMP(last_log) AS `last_log_ts` FROM `tbl_admin_user` ORDER BY `username` ASC";But here is the problem. If I use:
Code: Select all
echo $user['last_log'] . " - " . date('Y-m-d H:i:s', $data['last_log_ts']);Any clues for me on this one ... I've been staring at this for far too long.2007-02-27 21:55:16 - 2007-02-27 10:55:16
Cheers