homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

Is there a way to find the time and date an entry was added?

 9:08 pm on Jul 15, 2010 (gmt 0)

Pretty simple question here (at least I think).

I'm fairly new to PHP/MySQL but I have a form where users can register. It stores all of their information in a MySQL database I created and it works great. The only thing I'm curious about is I would like to find dates/times for each individual entry so that I can see patterns and statistics with people who sign up. I'm using PHPMyAdmin and I'm not sure if there is a way to set this up on my table or not?

Any help would be greatly appreciated as I'm pretty new to MySQL as I said before.



 8:25 am on Jul 16, 2010 (gmt 0)

you should look at the TIMESTAMP data type with a DEFAULT CURRENT_TIMESTAMP property [dev.mysql.com]


 3:31 pm on Jul 16, 2010 (gmt 0)

Assuming you have a DATETIME field in your DB that you populate when someone registers- yes, it is quite easy. If you are not already tracking the date that way, it would very difficult and would probably involve parsing through your DB's log file (icky!).


 3:36 pm on Jul 16, 2010 (gmt 0)

Assuming you aren't tracking the time that entries are made you want to execute this:

alter table table_name add column date_entered TIMESTAMP;


alter table table_name alter column date_entered set default now();

This way you won't have to update any SQL statements that insert into your tables as this column will default to now() every time a new row is inserted.

Once you have that in place all you do is create a SQL statement that looks for rows with a date > then 7 days ago and < now()

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved