This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > June 2004 > Inserting current date in form





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Inserting current date in form
megajam02

2004-06-11, 4:14 am

Ok. I have a new user registration form. I'd like to be able to insert the
current date along with all of the other user data when the user submits the
form. I created a hidden field called 'createdate' and linked it to the
'createdate' field in my database, which is a DATE field. I can't figure out
how to actually insert the current date into the createdate field on my form.

I'm using mysql on the backend, if it makes any difference.

Thanks,
Chris

genuine airguitar

2004-06-11, 12:14 pm

Try this:

<input type="hidden" name="createdate" value="<%=FormatDateTime(Date, 1) %>">

That's providing your using ASP. Change the "1" depending on the format you want.

Hope that helps
Mark Bodoh

2004-06-11, 12:14 pm

I don't know about mysql but I bet you can have the database insert
the current date by default when the record is inserted. In Access,
it's done by defining the column in the database with a default value
of Now(). mysql should have a similar function. That way you don't
have to code it on your page and that's a little less data to push
across the wire.
megajam02

2004-06-11, 7:14 pm

I ended up making the date field in mysql a TIMESTAMP field. That seemed to work, although the date format is quite heinous..

Thanks for the suggestions guys..
Joe Makowiec

2004-06-11, 7:15 pm

On 11 Jun 2004 in macromedia.dreamweaver, megajam02 wrote:

> I ended up making the date field in mysql a TIMESTAMP field. That
> seemed to work, although the date format is quite heinous..


It shouldn't matter what format the date is stored in; just format it
when you extract it. PHP (I assume you're using PHP to access the
database?) has some great date formatting capability.

http://us3.php.net/manual/en/function.date.php

--
Joe Makowiec can be reached at:
http://makowiec.org/contact/?Joe
Sponsored Links


Copyright 2003 - 2009 forum4designers.com  Software forum  Computer Hardware reviews