Hello, I'm wondering how UNIX_TIMESTAMP works in MySQL. I tried reading about it, but all that expert-mumbo-jumbo made absolutely no sense to me. Can anybody please explain a bit about it?
Also, I'm trying to make a " Users Online " function and I'm wondering what is the best way to insert and extract the date and time from a table?
UNIX_TIMESTAMP
Re: UNIX_TIMESTAMP
One way to see it, essentially, is as the time() function in PHP. It just returns the amount of seconds since 1970-01-01 00:00:00
Please check out my CodeCanyon items.
Re: UNIX_TIMESTAMP
Inserting a timestamp would probably be easiest as you can do the maths with a single number much easier than if you stored a MySQL date format value.Temor wrote:Also, I'm trying to make a " Users Online " function and I'm wondering what is the best way to insert and extract the date and time from a table?
Re: UNIX_TIMESTAMP
What is the most reliable way to insert a timestamp?
I really suck at MySQL, so I'm not really sure about anything when it comes to inserting time and dates in a table
I really suck at MySQL, so I'm not really sure about anything when it comes to inserting time and dates in a table
Re: UNIX_TIMESTAMP
You can use the UNIX_TIMESTAMP() function in the VALUES part of the INSERT query, for example,
INSERT INTO `table` (`list`, `of`, `columns`) VALUES ('value', UNIX_TIMESTAMP(), 'other value');would insert a timestamp into the of column in the table table.
Re: UNIX_TIMESTAMP
Alright, I'll try it outjacek wrote:You can use the UNIX_TIMESTAMP() function in the VALUES part of the INSERT query, for example,
INSERT INTO `table` (`list`, `of`, `columns`) VALUES ('value', UNIX_TIMESTAMP(), 'other value');would insert a timestamp into the of column in the table table.
Re: UNIX_TIMESTAMP
I've hit a snag... I got it to insert it properly. But it keeps repeating itself over and over every time I call the function. ON DUPLICATE KEY ENTRY gives me an error.
Here's my current SQL statement:
Here's my current SQL statement:
$sql = " INSERT INTO `users_online` (`username`,`last_activity`,`null`) VALUES ('{$username}', UNIX_TIMESTAMP(),'null')"; mysql_query($sql);Please help me
Re: UNIX_TIMESTAMP
What do you mean by that.Temor wrote:But it keeps repeating itself over and over every time I call the function
I think you mean ON DUPLICATE KEY UPDATE, also what is the error ?Temor wrote:ON DUPLICATE KEY ENTRY gives me an error.