Inserting date automatically into a from field?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dysonline
Forum Newbie
Posts: 1
Joined: Sat Jul 03, 2004 1:00 pm

Inserting date automatically into a from field?

Post by dysonline »

I'm sure this is really simple but can't manage to do it. I want to insert the date automatically into a form field so the user doesn't have to type it themselves. Please help!
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Code: Select all

<?php

$date = date("l, F d, Y");

echo "<form action="page.php" method="POST">";
echo "<text input=text value="$date" name=blah>";
etc etc


?>
modfiy the $date var to whatever format you want. the thing you want is value= in your form, assign it the date var.

kudos
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

Post by andylyon87 »

There is a date function in php where different letters stand for different things:
eg
date(M);
would show jun

if you go on http://www.php.net and search date it should tell you the other options
Post Reply