Drezard Posted March 25, 2007 Share Posted March 25, 2007 Hello, Whenever I store an output from Date(YmdGi); into my mysql database. It always comes up as the same number... E.G: My database looks like this Timestamp | Username 2147483647 John 2147483647 Jack 2147483647 Peter Here is my script: // $username = Form data $timestamp = date(YmdGi); echo "$timestamp"; $result ("INSERT INTO users (timestamp, username) VALUES ('$timestamp', '$username')"); When I run this script it outputs something like 200703251056 but then in the database its always that same number.... What am i doing wrong? - Cheers, Daniel Quote Link to comment https://forums.phpfreaks.com/topic/44182-date-and-mysql/ Share on other sites More sharing options...
DeathStar Posted March 25, 2007 Share Posted March 25, 2007 Try this date function: $date = date("H:i d/m/Y"); That would output 18:39 24/03/2007 Quote Link to comment https://forums.phpfreaks.com/topic/44182-date-and-mysql/#findComment-214544 Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 What is the type of "timestamp" in your database? Quote Link to comment https://forums.phpfreaks.com/topic/44182-date-and-mysql/#findComment-214545 Share on other sites More sharing options...
DeathStar Posted March 25, 2007 Share Posted March 25, 2007 date(YmdGi); Think its also UNIX_TIMESTAMP(); Quote Link to comment https://forums.phpfreaks.com/topic/44182-date-and-mysql/#findComment-214549 Share on other sites More sharing options...
DeathStar Posted March 25, 2007 Share Posted March 25, 2007 For a users online script useing the UNIX_TIMESTAMP(); put this in the page where it logs the time of the user: mysql_query("UPDATE `tablename` SET `last_online`=UNIX_TIMESTAMP() WHERE `mid`='$id'"); The users online script itself: $names = mysql_query("SELECT `name` FROM `tablename` WHERE `last_online`=UNIX_TIMESTAMP()-300"); //simple calculation 60*5 = 300 echo $names; Quote Link to comment https://forums.phpfreaks.com/topic/44182-date-and-mysql/#findComment-214552 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.