Inserting Dates into a postgresql database

From: Date: Tue, 29 Apr 2003 09:05:44 +0000
Subject: Inserting Dates into a postgresql database
Groups: php.general 
Request: Send a blank email to php-general+get-145599@lists.php.net to get a copy of this message
Hi, I'm having trouble formatting a date to be inserted into a postgresql date field. Basically I have a feedback form and I want to log the date (day/month/year) in the database as well as the feedback form fields. This is my current effort: --------> $today = getdate(); $year = $today['year']; $month = $today['month']; $day = $today['mday']; $datetoday = $year-$month-$day; include('../includes/conn.php'); $insertFB = "INSERT INTO tblFeedback (fbName,fbEmail,fbType,fbDetails,fbDate) VALUES ('$_POST['fbName']','$_POST['fbEmail']','$_POST['fbType']','$_POST['fbDe tails']','$datetoday')"; $resInsertFB = pg_query($connection,$insertFB); <-------- I tried to create the $datetoday string because I kept getting errors telling me that my database field was a 'date' field and my date() value was an integrer. With this current version I get the following error: -------> Warning: pg_query() [function.pg-query]: Query failed: ERROR: Bad date external representation '1974' . in /usr/local/etc/apache_1.3.27/htdocs/feedback/feedback2.php on line 16 Error: ERROR: Bad date external representation '1974' <------ I'm pretty new to both PHP and postgres so any help provided would be gratefully received. Cheers, Matt

« previous php.general (#145599) next »