JRS: In article <11**********************@f14g2000cwb.googlegroups .com>
, dated Tue, 10 May 2005 13:57:42, seen in news:comp.lang.javascript,
ts******@gmail.com posted :
Ok. I have an ASP page that send data to a database. One of the fields
is "Date" (no quotes). The form name is FrontPage_Form1. I would like
the Date field to auto populate. So, I did some research and the only
thing that I could come up with that worked was this:
<script>
function upDate() {
FrontPage_Form1.Date.value=new Date();
}
setInterval('upDate()',1000);
</script>
While this is good, I need the date to be displayed as MM/DD/YY or
MM/DD/YYYY. Help me please....
It's less good than you think, unless you have omitted relevant
information, since the text string format obtained that way is not well
defined.
Only chronologically backward locations still use FFF dates; it is
recommended that ISO 8601 / ANSI X3.30-1985(R1991), FIPS PUB 4-1, 4-2
be followed. Use YYYY-MM-DD or YYYY/MM/DD, in order that there can be
no misunderstanding.
Note that setInterval(..., 1000) does not necessarily update every
second. However, one can get an update every second (unless the client
CPU is pre-empted) by using setTimeout(..., X), see via below.
If you need to know the date and time by the client computer, can you
not get it loaded into ...Date.value as part of the Submit process? If
you only need the correct date and time, that's better done on the
server - though the possible consequences of using a date and time that
the user may think are wrong should be considered.
One should read a newsgroup's FAQ before posting. See below.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.