Each record I add to a database I like to enter the current date and users name to the end of the record. What function do you use to get the current date?
$DateAdded = ?
TIA
Frank
Well that would be a timestamp field in the database for me. It automatically places the current time in when its updated to null so when you create the tuple it is initialized to the current time.
Alternatively I'd use either [man]date[/man] if I wanted a formatted date/time or [man]time[/man] if I wanted a UNIX timestamp.
99.9% of what I do with dates is like this for the current date and time... $DateAdded = time();
I have found that is is easier to manipulate the dates when in this format (seconds since the epoch). I personally don't rely on the functionality of the timestamp type field to automatically fill in. (I have never had problems with it, but I would rather push the info myself)
Note: MySQL's date formatting functions are not limited to epoch time in the way of PHP's unix timestamp based functions 🙂
Hi, you can just use the NOW() function in your SQL statement, without using any php var...
"insert into mytable values(0,...,NOW(),...)"
bye