Now -- populating textbox with date/time stamp

M

middletree

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
 
M

Martin Honnen

middletree said:
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

VBScript's Now result is locale dependent, for instance on my system I
get e.g.
25.07.2005 18:52:51
As for JavaScript, you get a Date object with current date and time with
var now = new Date();
then you need to write your own function to create some output format
like you want.
 
D

Dr John Stockton

JRS: In article <[email protected]
t>, dated Mon, 25 Jul 2005 11:43:11, seen in
middletree said:
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.
 
M

mt

The default assumption in this newsgroup is that script is for the
World-Wide Web : note the first two W characters in particular.

Understood. I erred in not pointing out that in my case, I am working on an
Intranet app that will have zero chance of getting viewed by people outside
of my company, which is an American one. It can be debated which format
is best, but my boss is the boss, and he wants the format I mentioned in my
OP. So based on that, I was seeking help, as a person who barely knows
Javascript.
 

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,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top