JRS: In article <42***********************@authen.white.readfreene ws.ne
t>, dated Mon, 25 Jul 2005 11:43:11, seen in news:comp.lang.javascript,
middletree <mi********@verywarmmail.com> posted :
Is there a script that will populate, with a click, a textbox with the
equivalent of the ASP/VBScript Now() function? In ohter words, I'd like it
to be in this format:
7/25/2005 10:58:39 AM
The default assumption in this newsgroup is that script is for the
World-Wide Web : note the first two W characters in particular.
That's a damfool format for use internationally, since a very
substantial majority of countries use either YYYY MM DD or DD MM YYYY,
which each have the numeric fields in a logical order.
Therefore, for numeric dates, one should always use the unambiguous form
YYYY MM DD - it is believed that even Americans can understand it.
One should also, of course, use the 24-hour clock - same comment.
By the way, you are wrong in saying that VBS Now() returns that form; it
does not, it returns a value of variant CDate, which is a count of days
(probably in IEEE Double format) from 1899-12-30 00:00:00 local time.
One can do simple arithmetic - addition and subtraction - on that CDate
and it remains a CDate. It is the conversion from CDate to string that
imposes a character-based format on the data; that format is localised,
and it is not always safe to assume anything about the localisation.
For date formatting in javascript, see via sig 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.