Page 1 of 1

[SOLVED] How to default todays date in INPUT TYPE="text

Posted: Wed Apr 21, 2004 11:50 am
by bironeb
I am creating a form, and one of the fields is INPUT TYPE="text" for todays date. Does anyone know how I can default that field to todays date?

Thanks

Posted: Wed Apr 21, 2004 11:54 am
by bironeb
Here is an expample of the code Im using, but I need the input field to default with todays date.

Code: Select all

<P><STRONG>Entry Date:</STRONG><BR>
<INPUT TYPE="text" NAME="date" SIZE=18 MAXLENGTH=18></P>
I know to get todays date I can use:

Code: Select all

<?php
//get current date	
$today = date("l,F jS,Y");
?>
but I don't know how to get $today to default to the input field in the form.

Posted: Wed Apr 21, 2004 11:56 am
by JAM

Code: Select all

<INPUT TYPE="text" NAME="date" SIZE="18" MAXLENGTH="18" value="<?php echo date("l,F jS,Y"); ?>" />
...or...

Code: Select all

<?php
 $today = date("l,F jS,Y");
?>
<INPUT TYPE="text" NAME="date" SIZE="18" MAXLENGTH="18" value="<?php echo $today; ?>" />
...and so on...

Posted: Wed Apr 21, 2004 12:00 pm
by bironeb
Great! that worked, thanks.

Posted: Wed Apr 21, 2004 12:02 pm
by JAM
Nemas problemas.