Welcome to WebmasterWorld Guest from 54.167.102.69

Forum Moderators: open

Message Too Old, No Replies

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

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

Junior Member

5+ Year Member

joined:Mar 19, 2010
posts: 51
votes: 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 July 16, 2010 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


you should look at the TIMESTAMP data type with a DEFAULT CURRENT_TIMESTAMP property [dev.mysql.com]
3:31 pm on July 16, 2010 (gmt 0)

Moderator from US 

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

joined:Dec 10, 2005
posts:5550
votes: 24


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 July 16, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 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;

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