Date from Form to Database
Hi, How do I convert a date entered in a form in say a format like dd/mm/yy and convert it to a date that can be inserted into a database (which had a format yyyy-mm-dd)
Thanks
Hi, How do I convert a date entered in a form in say a format like dd/mm/yy and convert it to a date that can be inserted into a database (which had a format yyyy-mm-dd)
Thanks
Do you want to do it with WebAssist tools? Or, the hard way where you have to use the explode command to get the various date parts split apart and then re-apply them into variable the correct order.
If you have Validation Toolkit, you can apply a client validation and define the accept value and then in the same dialogue box, it allows you to pick a format to convert it to. This method, however, does use javascript to reformat the date.
Is it required in the form for the user to actually enter the date in question? Or is the actual system date sufficient? You could create a hidden input in the form to include the desired date format for you. Perhaps the following is a simple alternative?
<?php
$mydate = date('Y-m-d');
?>
<form>
<input name="date" type="hidden" value="<?php echo $mydate;?>" />
</form>
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.