Hi all,
I am saving the date and time that a user logs in into a MySql database table. The field is set to "datetime" and I am setting the value like this:
$date = date ("Y-m-d h:i:s");
Here is the SQL Insert:
The problem that I am having is that the time showing is always shown as AM, except the 12:00 hour that shows as PM. Thus, it looks like users are logging in at 1:30 in the morning when they are really logging in at 1:30 in the afternoon.PHP Code:$query_Insert2 = "INSERT INTO login (login_session_ID, login_users_ID, login_sec_level, login_teach_ID, login_scol_ID, login_date, login_time, login_remote_host, login_remote_IP )
VALUES ('$session','$users_ID','$sec_level','$teach_ID','$scol_ID','$date','1','$host','$ip')";
Here is the SQL for displaying the results:
When I look in the database, the datetime field simply shows "2008-05-08 01:55:09" There is no AM/PM or 24 hr clock so I don't know what is morning or night.PHP Code:$query_recSessions = sprintf("SELECT *, DATE_FORMAT(login_date, '%%c/%%e/%%y %%r') as date_time2 FROM login WHERE login_users_ID = '%s' ORDER BY login_date DESC", $colname_recSessions);
So, is the problem with my script or the database? And, how do I fix it to save the right time of day?
Also, since I have the user's general location in their profile can I either save to or display from the database their correct time based on their time zone. Right now everyone sees the server time which is US/Pacific.
Thanks,
sk






Bookmarks