I have a function where the user will add or update a record in a table and one of the fields to be updated is a date field.
I want the user to be able to be able to enter the date in mm/dd/yy format instead of the standard yyyy-mm-dd format. If they use the mm/dd/yy format right now, the date gets screwed up.
What code do I need to add for the conversion of the date when they enter it?
Here is the current code:
<pre>
<?php
// *** Insert Record: construct a sql insert statement and execute it
if (isset($MM_insert)) {
// create the sql insert statement
$MM_tableValues = "";
$MM_dbValues = "";
for ( $i=0; $i+1 < sizeof($MM_fields); ($i=$i+2)) {
$formVal = $MM_fields[$i+1];
$MM_typesArray = explode(",", $MM_columns[$i+1]);
$delim = $MM_typesArray[0];
if($delim=="none") $delim="";
$altVal = $MM_typesArray[1];
if($altVal=="none") $altVal="";
$emptyVal = $MM_typesArray[2];
if($emptyVal=="none") $emptyVal="";
if ($formVal == "" || !isset($formVal)) {
$formVal = $emptyVal;
}
else {
if ($altVal != "") {
$formVal = $altVal;
}
else if ($delim == "'") { // escape quotes
$formVal = $delim . $formVal . $delim;
//$formVal = "'" . str_replace("'","\'",$formVal) . "'";
}
else {
$formVal = $delim . $formVal . $delim;
}
}
if ($i == 0) {
$MM_tableValues = $MM_tableValues . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . $formVal;
}
else {
$MM_tableValues = $MM_tableValues . "," . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . "," . $formVal;
}
}
$MM_editQuery = "insert into " . $MM_editTable . " (" . $MM_tableValues . ") values (" . $MM_dbValues . ")";
if ($MM_abortEdit!=1) {
// execute the insert
$queryrs = $news->Execute($MM_editQuery) or DIE($news->ErrorMsg());
if ($MM_editRedirectUrl) {
header ("Location: $MM_editRedirectUrl");
}
}
}
?></pre>
Thanks
Charles.