I am creating a system which updates the user activity when something is done.
I have a variable $userhistory= 'User edited '.$info.' on July 14 2010 or (07-14-2010);
I want to know how can i get the date automatically. for sql query i am using NOW(), but in a variable like $userhistory how do i get the date and it want it only in either of these forms. not along with the time. Also, I am updating the column userhistory in the database, which is a text field. Is this the correct way to do it? How can i save only 5 or 10 of the last few updates?
You can do it without PHP as well.
If you are using NOW() when you update or write an entry to the database, the column storing the date (userhistory?) should be of DATETIME type.
Then you'd you'd run your SQL as normal :
Then in PHP, use date() on the database result to format it accordingly: