When the information is passed from the form, you need to take the date and convert it into the Unix Timestamp using:
list($month, $day, $year) = split('/', $date);
$timeStamp = mktime(0, 0, 0, $month, $day, $year);
Where $date is the date that was input in the form. Which means you could just have:
list($month, $day, $year) = split('/', $_POST['gig_Date']);
$timeStamp = mktime(0, 0, 0, $month, $day, $year);
Now you have the Unix Timestamp in the variable $timeStamp.
For your MySQL table your gigDate field (or whatever you called it) could be a Date or Timestamp. To insert this timestamp you’d use something like:
mysql_query("INSERT INTO gigs (gigID, gigDate, gigLocation, gigDetails) VALUES ('', FROM_UNIXTIME($timeStamp), 'Some bar', 'Gig details!')");
The FROM_UNIXTIME() is the key. It’ll convert the timestamp into the type for you for your field type.
Now when you want to select from the database you’re not going to get a unix timestamp returned to you. Depending on the field type you may get YYYY-MM-DD. You could just output that as is, but that’s not a very normal date for people to read. You may want it as MM/DD/YYYY. Which means you could either use PHP to split the date like we did above and just output it as you want it. Or you can get the date field from MySQL using UNIX_TIMESTAMP() and use the PHP date function to make the date the way you want it. That could look something like:
$result = mysql_query("SELECT UNIX_TIMESTAMP(gigDate) AS date, gigLocation, gigDetails FROM gigs LIMIT 3");
while($row = mysql_fetch_array($result)){
echo "Date: " . date('n/j/Y', $row['date']) . "<br />";
echo "Location: " . $row['gigLocation'] . "<br />";
echo "Details: " . $row['gigDetails'];
}
And well, there you go.
BTW - I know the PHP and the MySQL code isn’t coded in the best possible way. And I left out things I normally would do, but it’s just an example to show you how to work with the Unix Timestamp, MySQL and PHP.
On more thing – I created a MySQL database to test the code to make sure it worked.
I didn’t want you using code that may not be right. It’s not copy and use code either, if you want to use it make sure to make the changes to the MySQL table information so it works with your database. That goes for the variables as well.