PDA

View Full Version : Date Stamp


SmEdD
06-19-2003, 04:47 AM
Alright I'm having trouble with one of may hacks because I want it to record the date the entry was made (i.e. When you post it automaticly adds the date.) Any one know the code for this? Or how abouts to do it?

Cloudrunner
06-19-2003, 05:13 AM
If you are inputting the date directly into the database, then simply use NOW() in place of a variable.

for example for an insert statement:
INSERT INTO forum (id,date,whatever) VALUES ('1', NOW(), 'whatever');

For an update statement:
UPDATE forum SET id = '1', date = NOW(), whatever = 'whatever' WHERE id = '1';

then simply write your script in PHP to translate the date / time stamp into a more asthetic view.

What format MySQL uses will be determined by the column type. i.e. a 'DATE' type will only give today's date, whereas a datetime type will give a hash comprised of the date, and current time down to the second.

SmEdD
06-19-2003, 05:50 AM
Hey thanks alot. When I can release this hack I'm sure many will love it. I have posted about it but I have done so much new stuff to it.

It's for vb3 so can't release yet.