473,385 Members | 2,210 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,385 software developers and data experts.

Weird date stuff...

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

Jul 23 '05 #1
5 1604
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" <ki********@verizon.net> wrote in message
news:Kk*****************@nwrddc03.gnilink.net...
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

Jul 23 '05 #2
Lee
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/

Jul 23 '05 #3
>>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" <RE**************@cox.net> wrote in message
news:cf*********@drn.newsguy.com...
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/

Jul 23 '05 #4
On Sun, 15 Aug 2004 04:46:05 GMT, John Kiernan <ki********@verizon.net>
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
Jul 23 '05 #5
JRS: In article <hU*****************@nwrddc03.gnilink.net>, dated Sun,
15 Aug 2004 04:46:05, seen in news:comp.lang.javascript, John Kiernan
<ki********@verizon.net> 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.
Jul 23 '05 #6

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

Similar topics

3
by: zorro | last post by:
Hello there, I'm really stumped... I'm fetching a web page with a script and parsing it. There is a problem because the response inserts '8 1ff8' in random places. For example, I get things...
5
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: bas jaburg | last post by:
Hi, I am using the Microsoft Application BuildingBolock (Freudian slip, hahaha) Exception Management and am using a CustomPublisher. This goes fine and it write's stuff the Windows EventLog. ...
5
by: Coleen | last post by:
Hi all :-) I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after... I'm trying to get the date to go to the...
5
by: Pupeno | last post by:
Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print "getStatus(self=%s)"...
12
by: MQ.john | last post by:
//Working Example: #include <stdio.h> #include <time.h> int main () { time_t rawtime; /* define rawtime as time_t */ time ( &rawtime );
2
by: sherifffruitfly | last post by:
Hi, I'm using an adaptation of excel-reading code that's all over the internet - I don't much like or understand it, but it has worked for me in the past.... beggars can't be choosers... : ...
5
by: robinsiebler | last post by:
I have a data structure that looks like this: # dates = {'2007': {'25': {'06/23/07': {'aerosmith': , # 'Metallica': }, # 'last_song': }}}...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.