Welcome to WebmasterWorld Guest from 54.204.165.156

Forum Moderators: open

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

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

5+ Year Member



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)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



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)

WebmasterWorld Senior Member demaestro is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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;

Then...

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()
 

Featured Threads

Hot Threads This Week

Hot Threads This Month