Update Date
Posted: Mon Aug 30, 2004 5:01 pm
I have a text box which stores a date from a table I have in MySQL. I want the user to be able to change the date if they would like which works fine, the problem I'm having is I have to display the date in the text box as dd-mmm-yyyy. If the user updates another field and leaves the date as that format MySQL doesn't recognize the date so it changes the date to NULL. I tried the Date() function but it changes the date to 1969-12-31. How can I change the format of the text box to be MySQL's format before the database is updated? Here is the code I currently have.
Code: Select all
<?php
$p_priority=date("Y-m-d",$_POST[$priorityfield]);
$sql="UPDATE tblITPriorities SET dueDate='".$duedate."', priority='".$p_priority."', completed='".$p_completed."', dateCompleted='".$datecompleted."' WHERE ID=".$p_id.";";
mysql_query($sql,$cnx);
?>