Forum Moderators: coopster
$date = date("D j M Y, G:ia");
<input type="hidden" name="adddate" value="<? echo $date;?>">
<input type="text" name="name">
Create a VARCHAR field in your database to store the value of $adddate.
INSERT INTO table (namefield, datefield) VALUES ($name, $adddate)
:)
How would i modify this to make the date in my database read more like 02/31/2004?
See the PHP reference for the date() function, here:
[uk.php.net...]
You just need to change the letters in the format string to make the date appear just how you want it...
(1) display it in any way you want
(2) if you later decide to change the way you want to display it, this is very straightforward
(3) it is so much easier to do calculations on the date e.g. if you wanted to say that the user has been a member for x days (e.g. a free trial period maybe) - get the date value (which is represented as the number of seconds from 1 January 1970), minus it from the current date/time to get the number of seconds since signup or
(4) if you wanted to query your database to see who signed up in the last 30 days for example - "select username from members where signupdate > 'x'" .