Thanks for this George. I am populating the datetime field from user input, and users can change the date if they need to. The problem I have is with validation. I think I will need to use some kind of regular expression to check that the date has been entered in the correct format, but I am not sure what. Steven -----Original Message----- From: George Pitcher [mailto:george.pitcher@xxxxxxxxxxx] Sent: 28 February 2005 13:31 To: S.D.Price Subject: RE: Validation of Primary Key Datetime variable Simon, Why not use a varchar datatype and populate it yourself. It can then be modified, but the data can still be displayed in the way you want, by being a bit more creative with the code. I don't store dates as date datatype but as integers, that way I could, if required, move my code to a different db with no extra work. George > -----Original Message----- > From: S.D.Price [mailto:S.D.Price@xxxxxxxxxx] > Sent: 28 February 2005 12:38 pm > To: php-windows > Subject: Validation of Primary Key Datetime variable > > > Hi, I wonder if anyone can help. > > I have designed a newsblog which uses PHP and MySQL. Each news story > has a primary key which is the current date. The datatype used in > MySQL is "datetime". When stories are extracted from the database the > user can then navigate based on date order. > > When a user adds a news story to the database the current days date is > shown in the form using > > <dt> > <label for="publish_date"><?php echo $publish_datelabel > ?></label></dt> <dd><input type="text" name="publish_date" > id="publish_date" value="<?php echo date('Y-m-d H:i:s') ?>"/></dd> > > > This is the date added to the DB by default. > > However, the user must be able to change the date so that they can set > a date sometime in the future when they want the story to be > published. The only stories shown in the archive (and pulled through > to the home > page) are those which are before or on today's date. > > My problem is that I am not sure how to validate any changes made to > the $publish_date so that it will conform to the required datetime > range in MySQL and not give the useless answer 0000:00:00 00:00:00. > > Does anyone know how to do this? > Thanks > > Steven Price > > > > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php