![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hey, I'm completely new to javascript, but I've had some experience with Python (I know they're completely different; I don't want anyone replying just to say so). I'm having a problem with getting the current date and manipulating it as I need. What I'm doing is a directory with a bunch of HTML files of the name "DaysMM_DD.html", where MM and DD are 2 digit months and days respectively. I want to get today's file, and am having trouble with the code, seen below (with a couple stat markers): ========================== SCRIPT language=javascript !-- var stats="" var date=new Date(); var day=date.getDay(); var month=date.getMonth(); if (month.length==1){var full_month="0"+month; var stats=stats+"<BR>month was too short\n";}else{var full_month=month; var stats=stats+"<BR>month was the right length\n";}; if (day.length==1){var full_day="0"+day; var stats=stats+"<BR>day was too short\n";}else{var full_day=day; var stats=stats+"<BR>day was the right length\n";}; var URL="Days"+full_month+"_"+full_day+".html"; document.write("<H1 align=center><A HREF=\""+URL+"\">This Way!</A></H1>"); document.write(stats) -- /script ========================== 1. I'm getting the wrong date. It might be my browser has the wrong date, but I doubt that. 2. The length comparisons seem to be going wrong. I tried before to do month.string.length, but that seemed to be the wrong way. What am I doing wrong??? confusion between day (monday, tuesday...) and date (01, 02...31) |
#3
| |||
| |||
|
#4
| ||||
| ||||
|
|
Hey, I'm completely new to javascript, |
|
What I'm doing is a directory with a bunch of HTML files of the name "DaysMM_DD.html", where MM and DD are 2 digit months and days respectively. I want to get today's file, and am having trouble with the code, seen below (with a couple stat markers): ========================== SCRIPT language=javascript> // deprecated form !-- var stats="" var date=new Date(); var day=date.getDay(); // Day of Week, non-ISO form var month=date.getMonth(); // 0..11 ... 1. I'm getting the wrong date. It might be my browser has the wrong date, but I doubt that. |
|
2. The length comparisons seem to be going wrong. I tried before to do month.string.length, but that seemed to be the wrong way. |
|
What am I doing wrong??? |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Thanks for explaining how evil this Javascript support group is. |
|
I'll remember to avoid it at all costs. |
#7
| ||||
| ||||
|
|
DustanGroups (AT) gmail (DOT) com said the following on 2/6/2006 7:10 PM: Thanks for explaining how evil this Javascript support group is. Getting good answers is evil? |
|
Wow, didn't know that. But in any event, this is *not* a "support group". It is a "discussion group". If you get an answer, great. That is *not* its purpose though. |
|
I'll remember to avoid it at all costs. Don't make such wild promises, they might bite you later. |
|
-- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |
#8
| |||
| |||
|
|
You're not a customer. You're not always right. |
#9
| |||
| |||
|
|
DustanGroups (AT) gmail (DOT) com said: Thanks for explaining how evil this Javascript support group is. I'll remember to avoid it at all costs. You should avoid using Google to post to this (or any other) group, |
#10
| |||
| |||
|
|
Lee said the following on 2/7/2006 10:08 AM: DustanGroups (AT) gmail (DOT) com said: Thanks for explaining how evil this Javascript support group is. I'll remember to avoid it at all costs. You should avoid using Google to post to this (or any other) group, Not sure I agree with that. You should avoid Google Groups unless you understand it's pitfalls and how to get around them. |
![]() |
| Thread Tools | |
| Display Modes | |
| |