Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2005, 05:09 AM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to youquijano
Default setDate() problem

<html>
<head>
<script language="javascript">
function generate()
{
var current = new Date()
var days = new Array ('Sun','Mon','Tues','Wed','Thurs','Fri','Sat')
var months = new Array ('jan','feb','mar','apr','may','jun','jul','aug',' sept','oct','nov','dec')

for(i = 1 ; i <365 ; i++)
{
current.setDate(i);
document.write(i+". "+days[current.getDay()]+"--"+months[current.getMonth()]+" "+current.getDate()+", "+current.getYear()+"<br>")
}

}
</script>
</head>
<body onLoad=generate()>
</body>
</html>

i use this to generate 365 dates, but if you try to run this code, after the last date of the month, for example the month today is november, after november 30, the month will change to december. yup it is correct but the second date is wrong. please help me with this...
 
Old November 10th, 2005, 08:00 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

can you elaborate on this question. how do you mean the second date is wrong?

www.crmpicco.co.uk









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.