Re: Inserting date into a table

From: Date: Sat, 24 Apr 2004 08:42:49 +0000
Subject: Re: Inserting date into a table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184495@lists.php.net to get a copy of this message
Hi Pambos, you can use the function date in this manner: date("YmdGis"); because the type TIMESTAMP has the following format: YYYYMMDDHHMMSS, where: YYYY=year like 2004 MM=month like 04 DD=day like 24 HH=hour like 10 MM=minutes like 24 SS=seconds like 33 in this case date("YmdGis"); has the output 20040424102433 that is the right format for TIMESTAMP. ----- Original Message ----- From: "Pambos Nicolaou" <pambos_15@hotmail.com> To: <php-db@lists.php.net> Sent: Saturday, April 24, 2004 6:35 AM Subject: [PHP-DB] Inserting date into a table > I have created the table below: > > CREATE TABLE questions (ID INT NOT NULL AUTO_INCREMENT,name VARCHAR(30),day > TIMESTAMP, question TEXT, email VARCHAR(30),answer TEXT, PRIMARY KEY(ID)); > > I want to insert into the TIMESTAMP field the date automatically. How can I > do it using the insert command > > "INSERT INTO $table > > VALUES('','$name','TIMESTAMP','$question','$email','NULL')"; > > Thanks in advance > > Pambos Nicolaou > > _________________________________________________________________ > Protect your PC - get McAfee.com VirusScan Online > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#184495) next »