Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Weird date stuff...

Reply
Thread Tools

Weird date stuff...

 
 
John Kiernan
Guest
Posts: n/a
 
      08-15-2004
Hey JavaScript gurus!

Here's a weird one:

If I check (with an alert) this line:
vStrDate2 = vDate.toLocaleString();

I get: Saturday, August 14, 2004 7:57:30 PM (as I should)

but this operation...

vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" + vDate.getYear();

Avails me: 7/14/2004 (!?!?!?!)

I check my computer date and it definitely believes (as do I) that it is
August. Any idea why getmonth() thinks it's July?

Also, is there an easier way to get this American date string?

TIA!

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends



 
Reply With Quote
 
 
 
 
John Kiernan
Guest
Posts: n/a
 
      08-15-2004
Okay, I figured out I should just do:

vStrDate = vDate()

(I'm new, bear with me), but....

It still thinks it's July!?!?! Anybody know why?

TIA, redux...

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends


"John Kiernan" <(E-Mail Removed)> wrote in message
news:KkATc.6886$(E-Mail Removed)...
> Hey JavaScript gurus!
>
> Here's a weird one:
>
> If I check (with an alert) this line:
> vStrDate2 = vDate.toLocaleString();
>
> I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
>
> but this operation...
>
> vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" +

vDate.getYear();
>
> Avails me: 7/14/2004 (!?!?!?!)
>
> I check my computer date and it definitely believes (as do I) that it is
> August. Any idea why getmonth() thinks it's July?
>
> Also, is there an easier way to get this American date string?
>
> TIA!
>
> -- John Kiernan, KierPro Associates
> Custom VFP/Accounting Programming
> and Web interfaces
> VFP and/or SQL back ends
>
>
>



 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      08-15-2004
John Kiernan said:
>
>Hey JavaScript gurus!
>
>Here's a weird one:
>
>If I check (with an alert) this line:
>vStrDate2 = vDate.toLocaleString();
>
>I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
>
>but this operation...
>
>vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" + vDate.getYear();
>
>Avails me: 7/14/2004 (!?!?!?!)
>
>I check my computer date and it definitely believes (as do I) that it is
>August. Any idea why getmonth() thinks it's July?


It doesn't think it's July. Month 7 is August. Month 0 is January.
That makes it much easier to use as an index into an array of month names.

See the FAQ and the references it contains for date manipulation.
http://www.jibbering.com/faq/

 
Reply With Quote
 
John Kiernan
Guest
Posts: n/a
 
      08-15-2004
>>See the FAQ and the references it contains for date manipulation.
>>http://www.jibbering.com/faq/


I'd love to (and tried) but it's been down all day. Thanks for the answer
on the question though...

-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends


"Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> John Kiernan said:
> >
> >Hey JavaScript gurus!
> >
> >Here's a weird one:
> >
> >If I check (with an alert) this line:
> >vStrDate2 = vDate.toLocaleString();
> >
> >I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
> >
> >but this operation...
> >
> >vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" +

vDate.getYear();
> >
> >Avails me: 7/14/2004 (!?!?!?!)
> >
> >I check my computer date and it definitely believes (as do I) that it is
> >August. Any idea why getmonth() thinks it's July?

>
> It doesn't think it's July. Month 7 is August. Month 0 is January.
> That makes it much easier to use as an index into an array of month names.
>
> See the FAQ and the references it contains for date manipulation.
> http://www.jibbering.com/faq/
>



 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      08-15-2004
On Sun, 15 Aug 2004 04:46:05 GMT, John Kiernan <(E-Mail Removed)>
wrote:

>>> See the FAQ and the references it contains for date manipulation.
>>> http://www.jibbering.com/faq/

>
> I'd love to (and tried) but it's been down all day. [...]


Yes, it has. However, the FAQ is posted three times a week. From the FAQ:

"The FAQ will currently be posted in two parts, one part (the
Quick Answers) on Mondays and Fridays, with the remainder posted
on wednesdays."

The post on Friday was made just before 1200 GMT.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      08-15-2004
JRS: In article <hUBTc.7485$(E-Mail Removed)>, dated Sun,
15 Aug 2004 04:46:05, seen in news:comp.lang.javascript, John Kiernan
<(E-Mail Removed)> posted :
>>>See the FAQ and the references it contains for date manipulation.
>>>http://www.jibbering.com/faq/

>
>I'd love to (and tried) but it's been down all day. Thanks for the answer
>on the question though...
>
>-- John Kiernan, KierPro Associates
>Custom VFP/Accounting Programming
>and Web interfaces
>VFP and/or SQL back ends


Responses should go after trimmed quotes. The correct signature
delimiter is a line containing only minus minus space . Agreed about
jibbering down-ness; perhaps there should be a mirror at a reliable ISP?
Garbo might be willing to take it, and Garbo is itself mirrored ...


>> >Avails me: 7/14/2004 (!?!?!?!)


For Web use, the Web being international, you should use 2004-08-14
19:57:30, and add a time zone indication. AIUI, YYYY-MM-DD is in FIPS.


>> It doesn't think it's July. Month 7 is August. Month 0 is January.
>> That makes it much easier to use as an index into an array of month names.


You exaggerate. Adding 1, or using MNA = ['', 'Jan', 'Feb', ... is not
really difficult.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP General 11 11-08-2003 11:24 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments