How to populate the current date and time stamp on to an html form????

S

srini

Hi experts,

I am developing one html form for our intranet users. I have a field
called "SubmitDate", which is a plain text field and when the user
opens the form, the form should populate the submit date with the
current date and time stamp in PST format. Example: 4/14/2004 9:39:59
AM.
This is California time.

I know that we can use now() function in some scripting languages.
Say, if I use JavaScript client-side code, how would I write that
little piece of code?

Can some one kindly send me the code part for populating a date field
with the current date and time stamp?

Thanks in advance,
Srini
 
H

Hywel

schimata2 said:
Hi experts,

I am developing one html form for our intranet users. I have a field
called "SubmitDate", which is a plain text field and when the user
opens the form, the form should populate the submit date with the
current date and time stamp in PST format. Example: 4/14/2004 9:39:59
AM.

What's the point have having the user key that information in? Why not
either get the server to write the value to the field when the HTML
document is created, or add the functionality to server-side the form
handler.
This is California time.

There's nice.
I know that we can use now() function in some scripting languages.
Say, if I use JavaScript client-side code, how would I write that
little piece of code?
http://tinyurl.com/2er7n


Can some one kindly send me the code part for populating a date field
with the current date and time stamp?

Do it server-side. If you do it on the client you may not get the
date/time that you're expecting.
 
S

SpaceGirl

srini said:
Hi experts,

I am developing one html form for our intranet users. I have a field
called "SubmitDate", which is a plain text field and when the user
opens the form, the form should populate the submit date with the
current date and time stamp in PST format. Example: 4/14/2004 9:39:59
AM.
This is California time.

I know that we can use now() function in some scripting languages.
Say, if I use JavaScript client-side code, how would I write that
little piece of code?

Can some one kindly send me the code part for populating a date field
with the current date and time stamp?

Thanks in advance,
Srini

uh huh... server side. Asuming ASP:

<p> The current date/time is <%=now%>.</p>

Never do this stuff client side. If the user has JS disabled, your site wont
work.
 
B

Beauregard T. Shagnasty

Quoth the raven named SpaceGirl:
uh huh... server side. Asuming ASP:

<p> The current date/time is <%=now%>.</p>

Never do this stuff client side. If the user has JS disabled, your
site wont work.

And what if the visitor is in... Thailand? Or Newfoundland *?

IMO, you shouldn't even have a time field on the form. Let your server
do that. After all, it needs to validate the whole form anyway.

* 4½ hours from Pacific time.
 
N

Neal

And what if the visitor is in... Thailand? Or Newfoundland *?

I doubt the author wants to know the time at the user's home, but the time
the data was submitted relative to other submissions. Local server time is
fine for this purpose.

It's only when you care what time it is at their house that this will be a
problem - and why would you want to know that when accepting form data,
really?
 
B

Beauregard T. Shagnasty

Quoth the raven named Neal:
I doubt the author wants to know the time at the user's home, but
the time the data was submitted relative to other submissions.
Local server time is fine for this purpose.

That was part of my point. JavaScript will return the user's local
time, which would be generally useless.
It's only when you care what time it is at their house that this
will be a problem - and why would you want to know that when
accepting form data, really?

...as I also pointed out. <g> If the author needs the time for some
sort of first in, first out reason, the local server (if it _is_
local) is the only method that should be used.
 
M

Mitja

[...]
[...]

And what if the visitor is in... Thailand? Or Newfoundland *?

IMO, you shouldn't even have a time field on the form. Let your server
do that. After all, it needs to validate the whole form anyway.

* 4½ hours from Pacific time.

Um... "I am developing one html form for our intranet users" and so on...
Perhaps some TCP tunnelling?
 
B

Beauregard T. Shagnasty

Quoth the raven named Mitja:
[...]
And what if the visitor is in... Thailand? Or Newfoundland *?

Um... "I am developing one html form for our intranet users" and so
on...

Oh my. Sorry, I missed that word intranet. Damn, I hate it when that
happens! There probably won't be many Thais or Newfies using the form.
Perhaps some TCP tunnelling?

Perhaps. If the web page is being served on a company server, the
simple asp or php as others have posted should suffice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top