I've got several text boxes in a form that are the input to a SQL query. I need one of the boxes to auto populate with today's date but can't get it to work :
<td align="left"><INPUT TYPE="text" MAXLENGTH="10" SIZE="10" NAME="To_Date" id=To_Date value="'.date("m/d/y").'"/></td>
displays the following in the text box:
'.date(
Help is much appreciated!
Cheers,
Rene
Try with either one like
PHP in HTML :
<input type="text" value="<?php echo date('m/d/y');?>"/>
HTML in PHP :
<?php echo "<input type='text' value='".date('m/d/y')."'";?>
Dont mesh both PHP and HTML and another is better to write HTML in lower cases.
Not sure why everyone is using type="text"
type="date"When using php date in the input date value, make sure the format is correct.
If not it will not work.
Use the format Y-m-d (separted by hyphen but in reverse order)
<input type="date" value="<?php echo date("Y-m-d");?>">
d-m-Y (using the hyphen, but placing date at the start)
d/m/Y (using slash)
Y/m/d (using slash in reverse order)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With