Forum Moderators: coopster

Message Too Old, No Replies

Storing Dates?

         

mRmONKEY

5:50 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



hello

iam trying to design a script for sending mot reminders out 2 clients they sign up online then 10days before there mot expires the script sends a e-mail out reminding them what would be the best way to store the dates in my database?

cheers

Jon

coopster

6:12 pm on Jul 1, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, mRmONKEY!

The best way to store dates in any database is the DATE format (yyyy-mm-dd). If you need the time as well, use the TIMESTAMP format (yyyy-mm-dd hh:mm:ss). The reason for this is you will be able to use the DATE and TIME functions for querying those types of columns.

mRmONKEY

6:56 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



cheers mate ill give that a bash

many thanks

Jon

mRmONKEY

9:05 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



another question if i want three drop down fields can (Days, Months, Years) is they anyway i can do it so they all go into the same date field in the database?

cheers

jon

coopster

9:47 pm on Jul 1, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure. You might want to refine the edit checking, but I'll show you an option using MySQL...
$year = (isset [php.net]($_POST['year'])) ? $_POST['year'] : ''; 
$month = (isset($_POST['month'])) ? $_POST['month'] : '';
$day = (isset($_POST['day'])) ? $_POST['day'] : '';
if (checkdate [php.net]($month, $day, $year)) {
$sql = "INSERT INTO table (date) VALUES(CONCAT_WS('-', '$year', '$month', '$day'))";
}