473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

javascript equivalent for vbscript Date()-1

I'm looking to return DATE ONLY for yesterday's date. No seconds,
milliseconds. Formatted either yyyy/mm/dd or mm/dd/yyyy. VB does it so
easily Date()-1 will return 03/27/2007 if today is 03/28/2007. Why so
many hoops for javascript? Any ideas?

Mar 28 '07 #1
21 2778
Ivo
"shelleybobelly" <sh************@yahoo.comschreef in bericht
news:11**********************@e65g2000hsc.googlegr oups.com...
I'm looking to return DATE ONLY for yesterday's date. No seconds,
milliseconds. Formatted either yyyy/mm/dd or mm/dd/yyyy.
Never use the latter format. It 's highly confusing to a worldwide audience.

var x = new Date();
var s = x.getFullYear() + '/' + x.getMonth() + '/' + x.getDate();
alert( s );
VB does it so
easily Date()-1 will return 03/27/2007 if today is 03/28/2007. Why
so many hoops for javascript? Any ideas?
That 's a terribly good question. I guess the answer includes the
flexibility that Javascript offers by leaving all formatting up to us.
hth
ivo
http://4umi.com/web/javascript/ref.htm#date
Mar 28 '07 #2
Ivo
"Ivo" <no@thank.youschreef
"shelleybobelly" <sh************@yahoo.comschreef
>I'm looking to return DATE ONLY for yesterday's date.
I forgot to substract a day, one more line of code:

var x = new Date();
x.setDate( x.getDate() - 1 );
var s = x.getFullYear() + '/' + x.getMonth() + '/' + x.getDate();
alert( s );

hth
ivo
http://4umi.com/web/javascript/ref.htm#date
Mar 28 '07 #3
On Mar 28, 11:19 am, "Ivo" <n...@thank.youwrote:
I forgot to substract a day, one more line of code:

var x = new Date();
x.setDate( x.getDate() - 1 );
var s = x.getFullYear() + '/' + x.getMonth() + '/' + x.getDate();
alert( s );
or
var x = new Date();
var s = x.getFullYear() + '/' + x.getMonth() + '/' + (x.getDate()-1);
alert( s );

Mar 28 '07 #4
scripts.contact wrote:
On Mar 28, 11:19 am, "Ivo" <n...@thank.youwrote:
>I forgot to substract a day, one more line of code:

var x = new Date();
x.setDate( x.getDate() - 1 );
var s = x.getFullYear() + '/' + x.getMonth() + '/' + x.getDate();
alert( s );

or
var x = new Date();
var s = x.getFullYear() + '/' + x.getMonth() + '/' + (x.getDate()-1);
alert( s );
But getMonth() is zero-based so you'd have to add 1 correct? And what will
getDate()-1 do on the first of the month? Won't you get zero?
Mar 28 '07 #5
Rick Brandt said the following on 3/28/2007 3:44 PM:
scripts.contact wrote:
>On Mar 28, 11:19 am, "Ivo" <n...@thank.youwrote:
>>I forgot to substract a day, one more line of code:

var x = new Date();
x.setDate( x.getDate() - 1 );
var s = x.getFullYear() + '/' + x.getMonth() + '/' + x.getDate();
alert( s );
or
var x = new Date();
var s = x.getFullYear() + '/' + x.getMonth() + '/' + (x.getDate()-1);
alert( s );

But getMonth() is zero-based so you'd have to add 1 correct?
Did you test it?
And what will getDate()-1 do on the first of the month?
It will return a result that will probably surprise you if you test it
in several browsers.
Won't you get zero?
Did you test it? <g>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 28 '07 #6
In comp.lang.javascript message <11**********************@e65g2000hsc.go
oglegroups.com>, Wed, 28 Mar 2007 09:23:55, shelleybobelly
<sh************@yahoo.composted:
>I'm looking to return DATE ONLY for yesterday's date. No seconds,
milliseconds. Formatted either yyyy/mm/dd or mm/dd/yyyy. VB does it so
easily Date()-1 will return 03/27/2007 if today is 03/28/2007.
No; it is important to understand the language properly. In VB, Date or
Date() returns a value of type CDate with an integer value representing
the number of days from 1899-12-30 local = 0.

Then the default conversion to CStr gives the value in the date form set
as default in the operating system. In most places that will be either
of D M Y form or of Y M D form, but Americans prefer Fred Flintstone
Format.

>Why so
many hoops for javascript? Any ideas?
VBscript tends to provide a simple approach for the commonest business
need; javascript provides a set of primitives on which the programmer
can build.
The following will (except possibly once a year, for an hour, in the
Azores or thereabouts) return a local date string in the proper
international form, e.g. "2007-03-27".

function Lz(x) { return (x<10&&x>=0?"0":"") + x }

with (new Date()) { setDate(getDate()-1) ;
Str = getFullYear() + "-" + Lz(getMonth()+1) + "-" + Lz(getDate()) }

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Mar 28 '07 #7
In comp.lang.javascript message <46***********************@news.wanadoo.
nl>, Wed, 28 Mar 2007 19:19:49, Ivo <no@thank.youposted:
>"Ivo" <no@thank.youschreef
>"shelleybobelly" <sh************@yahoo.comschreef
>>I'm looking to return DATE ONLY for yesterday's date.

I forgot to substract a day, one more line of code:

var x = new Date();
x.setDate( x.getDate() - 1 );
var s = x.getFullYear() + '/' + x.getMonth() + '/' + x.getDate();
alert( s );
To look inept, a good way is to fail to test the code you propose.

Firstly, if run today that gives 2007/2/27 and on Saturday it should
give 2007/2/30. February 30th is uncommon.

Secondly, in all-numeric dates the month and date fields should always
be extended to 2 characters; today is 2007 03 28.

Thirdly, to be fully standard the separators should be "-", though
javascript cannot be relied on to read that form, preferring 2007/03/28.

<http://4umi.com/web/javascript/ref.htm#dateis a copy (probably) of an
imprecise source, and should not be recommended.

But the worldclock on that site is interesting; it seems to assume that
the state of Summer Time changes everywhere at the same instant as at
the user's location.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Mar 28 '07 #8
Ivo
"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
But the worldclock on that site is interesting; it seems to assume that
the state of Summer Time changes everywhere at the same instant as at
the user's location.
Thank you for your feedback. That reference page is in dire need of an
update, and has been for a while. It is made from a database full of
oneliner descriptions, which was itself in fact put together for other
purposes. And the whole site is in a state of constant improvement,
so it is only good to find more room for that :-) If you are the one who
shows up in my log as searching for "email", try 4umi.com/contact
(between you and me; it 's a well hidden page).

So, with your comments in mind, the code is now:
var x = new Date();
x.setDate( x.getDate() - 1 );
var s = [ x.getFullYear(), x.getMonth() + 1, x.getDate() ];
s = s.join( '-' ).replace( /\b(\d)\b/, '0$1' );
alert( s );

BTW, using a "with" block as in another branch in this thread seems
not very good practice:
http://www.javascripttoolbox.com/bestpractices/#with

--
Regards, Ivo, homing in on
http://4umi.com/web/javascript/worldclock.htm
Mar 29 '07 #9
Randy Webb wrote:
Rick Brandt said the following on 3/28/2007 3:44 PM:
scripts.contact wrote:
On Mar 28, 11:19 am, "Ivo" <n...@thank.youwrote:
I forgot to substract a day, one more line of code:

var x = new Date();
x.setDate( x.getDate() - 1 );
var s = x.getFullYear() + '/' + x.getMonth() + '/' +
x.getDate(); alert( s );

or
var x = new Date();
var s = x.getFullYear() + '/' + x.getMonth() + '/' +
(x.getDate()-1); alert( s );
But getMonth() is zero-based so you'd have to add 1 correct?

Did you test it?
Testing it in Firebug I get 2 which is last month (in non-js-speak).
And what will getDate()-1 do on the first of the month?

It will return a result that will probably surprise you if you test it
in several browsers.
Won't you get zero?

Did you test it? <g>
I get "2007/2/0". What am I missing?



Mar 29 '07 #10
Ivo wrote on 29 mrt 2007 in comp.lang.javascript:
"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
But the worldclock on that site is interesting; it seems to assume that
the state of Summer Time changes everywhere at the same instant as at
the user's location.

Thank you for your feedback. That reference page is in dire need of an
update, and has been for a while. It is made from a database full of
oneliner descriptions, which was itself in fact put together for other
purposes. And the whole site is in a state of constant improvement,
so it is only good to find more room for that :-) If you are the one who
shows up in my log as searching for "email", try 4umi.com/contact
(between you and me; it 's a well hidden page).

So, with your comments in mind, the code is now:
var x = new Date();
x.setDate( x.getDate() - 1 );
var s = [ x.getFullYear(), x.getMonth() + 1, x.getDate() ];
s = s.join( '-' ).replace( /\b(\d)\b/, '0$1' );
nice touch, that regex, however the global flag is missing:

s = s.join( '-' ).replace( /\b(\d)\b/g, '0$1' );
alert( s );

BTW, using a "with" block as in another branch in this thread seems
not very good practice:
http://www.javascripttoolbox.com/bestpractices/#with


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 29 '07 #11
On Wed, 28 Mar 2007 at 23:38:11, in comp.lang.javascript, Dr J R
Stockton wrote:

<snip>
>Secondly, in all-numeric dates the month and date fields should always
be extended to 2 characters; today is 2007 03 28.
<snip>

What nonsense. If I want my next birthday to be displayed as 29/7/2007
then that's what the programmer should damn-well code otherwise he won't
get paid and that will make him unhappy and I don't care.

John
--
John Harris
Mar 29 '07 #12
Lee
John G Harris said:
>
On Wed, 28 Mar 2007 at 23:38:11, in comp.lang.javascript, Dr J R
Stockton wrote:

<snip>
>>Secondly, in all-numeric dates the month and date fields should always
be extended to 2 characters; today is 2007 03 28.
<snip>

What nonsense. If I want my next birthday to be displayed as 29/7/2007
then that's what the programmer should damn-well code otherwise he won't
get paid and that will make him unhappy and I don't care.
The job market must be different in your part of the world, if you can
impose your whims over good practices.
--

Mar 29 '07 #13
Lee said the following on 3/29/2007 3:33 PM:
John G Harris said:
>On Wed, 28 Mar 2007 at 23:38:11, in comp.lang.javascript, Dr J R
Stockton wrote:

<snip>
>>Secondly, in all-numeric dates the month and date fields should always
be extended to 2 characters; today is 2007 03 28.
<snip>

What nonsense. If I want my next birthday to be displayed as 29/7/2007
then that's what the programmer should damn-well code otherwise he won't
get paid and that will make him unhappy and I don't care.

The job market must be different in your part of the world, if you can
impose your whims over good practices.
Then re-word it slightly:

If the boss wants the date to be displayed as 7/29/2007 then that's what
the programmer should damn-well code otherwise he won't get paid (and
probably get fired).

Or, is the job market in your part of the world where you can dictate to
your boss how you should write/code/display dates/data on a page?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 29 '07 #14
In comp.lang.javascript message <46**********************@news.wanadoo.n
l>, Thu, 29 Mar 2007 02:52:57, Ivo <no@thank.youposted:
>"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
But the worldclock on that site is interesting; it seems to assume that
the state of Summer Time changes everywhere at the same instant as at
the user's location.

Thank you for your feedback. That reference page is in dire need of an
update, and has been for a while. It is made from a database full of
oneliner descriptions, which was itself in fact put together for other
purposes.
The reference page is a mere copy of other defective material; it would
be easy to improve the one-liners of the Date Object.

For example, all references to 1970 need to include a UTC, and
"midnight" should not be used. "UTC 1970.0" is exact, and I don't see
how anyone intelligent enough to program successfully can fail to
understand it. Or "1970-01-01 00:00:00 UTC".

Method getFullYear does not return a 4-digit year - try
new Date(-5e13).getFullYear() and new Date(5e15).getFullYear() - it
returns a Number.
The worldclock page is best deleted, as a precaution against anyone
believing it.
And the whole site is in a state of constant improvement,
so it is only good to find more room for that :-) If you are the one who
shows up in my log as searching for "email", try 4umi.com/contact
(between you and me; it 's a well hidden page).
Probably me; I was in fact trying to find out who was responsible for
the site. One should never pay much attention to technical documents
that do not declare their authorship and give some indication of age.

>var s = [ x.getFullYear(), x.getMonth() + 1, x.getDate() ];
s = s.join( '-' ).replace( /\b(\d)\b/, '0$1' );
That is appreciably slower to run than
function Lz(x) { return (x<10?"0":"") + x }
s = x.getFullYear() + "-" + Lz(x.getMonth()+1) + "-" + Lz(x.getDate()) ;

>BTW, using a "with" block as in another branch in this thread seems
not very good practice:
http://www.javascripttoolbox.com/bestpractices/#with
That site has no real authority; and the argument in #with is not
entirely convincing when carefully examined.

If "with" is used wantonly and there are errors in the code, it can
indeed be difficult to see what is happening.

But when there is no global date object, and the "with" clearly uses a
Date Object, and the identifiers in the statement are not going to have
other meanings, using it can add no problems.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Mar 29 '07 #15
Lee
Randy Webb said:
>
Lee said the following on 3/29/2007 3:33 PM:
>John G Harris said:
>>On Wed, 28 Mar 2007 at 23:38:11, in comp.lang.javascript, Dr J R
Stockton wrote:

<snip>
Secondly, in all-numeric dates the month and date fields should always
be extended to 2 characters; today is 2007 03 28.
<snip>

What nonsense. If I want my next birthday to be displayed as 29/7/2007
then that's what the programmer should damn-well code otherwise he won't
get paid and that will make him unhappy and I don't care.

The job market must be different in your part of the world, if you can
impose your whims over good practices.

Then re-word it slightly:

If the boss wants the date to be displayed as 7/29/2007 then that's what
the programmer should damn-well code otherwise he won't get paid (and
probably get fired).

Or, is the job market in your part of the world where you can dictate to
your boss how you should write/code/display dates/data on a page?
If he makes bad decisions and won't listen to reason (or refuses to
explain his reasons), I'll go work for somebody else. He knows that,
and would rather compromise than have to replace me (or anyone else).
--

Mar 29 '07 #16
Ivo
"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
>>, Thu, 29 Mar 2007 02:52:57, Ivo <no@thank.youposted:
"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
For example, all references to 1970 need to include a UTC, and
"midnight" should not be used. "UTC 1970.0" is exact, and I don't
see how anyone intelligent enough to program successfully can fail
to understand it. Or "1970-01-01 00:00:00 UTC".

Method getFullYear does not return a 4-digit year - try
new Date(-5e13).getFullYear() and new Date(5e15).getFullYear() - it
returns a Number.
Interesting. The updated page will certainly benefit from these hints.
The worldclock page is best deleted, as a precaution against anyone
believing it.
Anyone blindly believing anything only deserves so, especially on the www.
People go online for information, not for knowledge. The page may be full of
inaccuracies, it may be one big lie (as was the page that I originally
copied), but it can satisfy much curiosity, ignite even more, and it may
spark a thought in one visitor about the wonders of our world. In that I
find satisfaction, until of course you convince me of some real evil in the
page.
Probably me; I was in fact trying to find out who was responsible for
the site. One should never pay much attention to technical documents
that do not declare their authorship and give some indication of age.
My picture of you has always been someone in his fifties, I cannot say why,
I don't remember such indication being prominently advertised on your site,
I must say. And if I told you I happen to turn 36 today, and gave you an url
such as http://www.vansandick.com/familie/kalender/?20070330 to make it look
convincing, wouldn't that be reason enough to be suspicious? Then why should
credibility of any text depend on the name under it? What matters is what
works. Especially technical texts are easy to judge by empirically trying
out the claims that are made. Experiment is key. That 's how information
becomes knowledge. Any text that shows me something I haven't tested yet, is
worthwhile, and I find that the older I get, more and more of such texts are
written by nameless youths.
>>BTW, using a "with" block as in another branch in this thread seems
not very good practice:
http://www.javascripttoolbox.com/bestpractices/#with

That site has no real authority; and the argument in #with is not
entirely convincing when carefully examined.
I 'm not building on their authority, just gave a pointer. The argument
could be expressed stronger, shall we say "The problem is that the
programmer has no way to verify that input1 or input2 are actually being
resolved as properties of the form elements array" is a bit long and
winding, but it stands solid. I don't think there are words that will
entirely convince you. Inside the 'with' block, there is no way to tell an
independent input2 from a 'with'ed input2. There is a ghost host object at
every level in the scope chain. Ay, there 's the rub. There is no defense
against the ambiguity created with 'with'. I also refer to a contemporary
thread started by Rasmus Kromann-Larsen, 'Eliminating "with"...', especially
the very first paragraph: "I'm currently writing a master thesis on static
analysis of JavaScript, and after investigating the with statement, it only
[became] even more evident to me that the with statement is indeed bad." See
for the arguments:
http://groups.google.nl/group/comp.l...77b6f155fd916a
If "with" is used wantonly and there are errors in the code, it can
indeed be difficult to see what is happening.
Like you say.
But when there is no global date object, and the "with" clearly
uses a Date Object, and the identifiers in the statement are not
going to have other meanings, using it can add no problems.
With all conditions met, I probably am with you on the Date object argument,
but I maintain that continuing to use 'with' sustains a flaw in the
language. We 're really better off without.
--
ever underage
Ivo
http://www.trust.onlyfools.com/
Mar 30 '07 #17
Dr J R Stockton wrote:
>BTW, using a "with" block as in another branch in this thread seems
not very good practice:
http://www.javascripttoolbox.com/bestpractices/#with
That site has no real authority;
How does a site acquire this "authority" anyway? If your site is referenced,
do you also state that it has no authority?
and the argument in #with is not
entirely convincing when carefully examined.
The word "avoid" is used instead of "don't ever use" because there are
always exceptions.
I personally feel that there is no convincing argument to ever use the
'with' statement, even where it will work correctly. There are other, less
error-prone, more readable ways to achieve the same result.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 30 '07 #18
On Thu, 29 Mar 2007 at 16:07:25, in comp.lang.javascript, Lee wrote:
>Randy Webb said:
>>
Lee said the following on 3/29/2007 3:33 PM:
>>John G Harris said:
On Wed, 28 Mar 2007 at 23:38:11, in comp.lang.javascript, Dr J R
Stockton wrote:

<snip>
Secondly, in all-numeric dates the month and date fields should always
be extended to 2 characters; today is 2007 03 28.
<snip>

What nonsense. If I want my next birthday to be displayed as 29/7/2007
then that's what the programmer should damn-well code otherwise he won't
get paid and that will make him unhappy and I don't care.

The job market must be different in your part of the world, if you can
impose your whims over good practices.

Then re-word it slightly:

If the boss wants the date to be displayed as 7/29/2007 then that's what
the programmer should damn-well code otherwise he won't get paid (and
probably get fired).

Or, is the job market in your part of the world where you can dictate to
your boss how you should write/code/display dates/data on a page?

If he makes bad decisions and won't listen to reason (or refuses to
explain his reasons), I'll go work for somebody else. He knows that,
and would rather compromise than have to replace me (or anyone else).
Who said anything about bosses? I'm a customer. If a software company or
freelance programmer won't write my party invitations the way I want
them written then they can buzz off and I'll find somebody else to do
the job.

In case you're still wondering, this is about customer requirements.
There are contexts where redundant zeroes in dates just aren't
acceptable. Saying you must *always* format a date in a particular way
regardless of context is wrong.

If you insist on displaying dates in a fixed punched card format then to
be logical you should cater for all the year numbers that javascript can
handle. Today is 0002007-03-30, I think.

John

--
John Harris
Mar 30 '07 #19
Lee
John G Harris said:
>
On Thu, 29 Mar 2007 at 16:07:25, in comp.lang.javascript, Lee wrote:
>>Randy Webb said:
>>>
Lee said the following on 3/29/2007 3:33 PM:
John G Harris said:
On Wed, 28 Mar 2007 at 23:38:11, in comp.lang.javascript, Dr J R
Stockton wrote:
>
<snip>
>Secondly, in all-numeric dates the month and date fields should always
>be extended to 2 characters; today is 2007 03 28.
<snip>
>
What nonsense. If I want my next birthday to be displayed as 29/7/2007
then that's what the programmer should damn-well code otherwise he won't
get paid and that will make him unhappy and I don't care.

The job market must be different in your part of the world, if you can
impose your whims over good practices.

Then re-word it slightly:

If the boss wants the date to be displayed as 7/29/2007 then that's what
the programmer should damn-well code otherwise he won't get paid (and
probably get fired).

Or, is the job market in your part of the world where you can dictate to
your boss how you should write/code/display dates/data on a page?

If he makes bad decisions and won't listen to reason (or refuses to
explain his reasons), I'll go work for somebody else. He knows that,
and would rather compromise than have to replace me (or anyone else).

Who said anything about bosses? I'm a customer. If a software company or
freelance programmer won't write my party invitations the way I want
them written then they can buzz off and I'll find somebody else to do
the job.

In case you're still wondering, this is about customer requirements.
There are contexts where redundant zeroes in dates just aren't
acceptable. Saying you must *always* format a date in a particular way
regardless of context is wrong.

If you insist on displaying dates in a fixed punched card format then to
be logical you should cater for all the year numbers that javascript can
handle. Today is 0002007-03-30, I think.
Nothing at all logical about that. You seem to be talking about
graphical design, not programming, so you're welcome to your whims.
--

Mar 30 '07 #20
In comp.lang.javascript message <46***********************@news.wanadoo.
nl>, Fri, 30 Mar 2007 03:27:09, Ivo <no@thank.youposted:
>"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
>>>, Thu, 29 Mar 2007 02:52:57, Ivo <no@thank.youposted:
"Dr J R Stockton" <jr*@merlyn.demon.co.ukschreef
For example, all references to 1970 need to include a UTC, and
"midnight" should not be used. "UTC 1970.0" is exact, and I don't
see how anyone intelligent enough to program successfully can fail
to understand it. Or "1970-01-01 00:00:00 UTC".

Method getFullYear does not return a 4-digit year - try
new Date(-5e13).getFullYear() and new Date(5e15).getFullYear() - it
returns a Number.

Interesting. The updated page will certainly benefit from these hints.
They are but examples, of course. You might say that all Date Methods
return Numbers, except where otherwise stated. Change GMT to UTC, or
use GMT/UTC. getTimezoneOffset() returns minutes, (UTC-local). setYear
presumes 1900-1999 if given 0-99, but not otherwise.

Method toLocaleString gives local time, not local zone. I guess you are
a Dutch resident; if so, your Zone is always UTC+1 but your time in
Summer is UTC+2.

Date.UTC is missing? valueOf is not there.

Math.Random does not return a random number between 0 and 1; it can
return 0.0 but should not return 1.0.

Math.round - rounding of x.5 needs mention.

String lacks charCodeAt ?

<http://4umi.com/web/javascript/clock.htm seems broken (XP sp2 IE6).

>Probably me; I was in fact trying to find out who was responsible for
the site. One should never pay much attention to technical documents
that do not declare their authorship and give some indication of age.
... ...
Any text that shows me something I haven't tested yet, is
worthwhile, and I find that the older I get, more and more of such texts are
written by nameless youths.
The name as an identifier of a real tangible person is not important; I
can only recall three or four named authors in News or Web who I've
personally met. But the presence of a full name in most cases allows
all the News/Web works of an author to be considered as a whole, and
indicates that the Net personality is willing to take responsibility for
the work and to risk his personal friends finding his Net work.

It can also be useful to be able to identify for preservation the works
of the recently deceased.

IMHO, the amount of interesting stuff on the Net that one has not yet
personally tested is so great that an indication of trustworthiness,
even if itself not entirely trustworthy, is useful.

If one recalls that someone, say me, has written something relevant,
then one can Google for the name and topic. Google reports 21,600,000
hits on Ivo, 1.270,000 for Ivo nl, but only 8 for "Ivo Tromp" (the
second Dutch surname that sprang to mind).

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Mar 30 '07 #21
In comp.lang.javascript message <ht**************@J.A830F0FF37FB96852AD0
8924D9443D28E23ED5CD>, Fri, 30 Mar 2007 21:12:54, John G Harris
<jo**@nospam.demon.co.ukposted:
>
If you insist on displaying dates in a fixed punched card format then to
be logical you should cater for all the year numbers that javascript can
handle. Today is 0002007-03-30, I think.
The javascript range is +- 10^8 days from UTC 1970.0, so you have there
a digit more than your argument justifies.

Today should, in agreement with ISO 8601:2004(E), be given as
2007-03-30; the standard has provision for extension of YYYY. But it
will no doubt be updated before AD 9999.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Mar 31 '07 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christopher Brandsdal | last post by:
Hi! I have a javascript serverside script that stores the "Date" command in a database. The problem is that I am in Norway, ans the server is in Florida! It's a BIG timedifference. When I...
5
by: John Davis | last post by:
When I create new documents in Dreamweaver, there are several choices for ASP creation: ASP JavaScript: run at client side?? ASP VBScript: run at server side?? ASP.NET C# ASP.NET VB I don't...
1
by: Colin Colin | last post by:
I downloaded a calendar.asp file that someone named Jacob "WickedPisser" Gilley made. It's a few years old but It works fine and it's what I was looking for without getting into ActiveX objects. ...
4
by: Targa | last post by:
How can I pull this ASP var into javascript? What is wrong with this statement? <% todaysdate = (now) response.write (todaysdate) %> <script language="JavaScript"><!-- var date = new Date();...
2
by: Fabrizio | last post by:
I have just put a internet webcam that save every 30 seconds a picture via ftp. I have an html file that display this picture file (the name of the file is always the same and the webcam delete the...
2
by: davidgordon | last post by:
Hi, I have some pages with this VBScript code, which obviously does not work in Firefox. How can I convert this to Javascript in order for my web page to work in Firefox ? It basically fills a...
10
by: Jim Ciotuszynski | last post by:
Is there an equivalent to the "button.attributes.add("onBlur","JavaScript:return somfunction();") ? I thought that vbscrpt would also do the same but when I run my code with the vbscript my...
3
by: polychrom | last post by:
What is Javascript equivalent for this VBScript line: Set WshShell = Nothing Thanks.
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.