![]() |
Ok, I admit it. I'm stupid, ok, now will you help me? (JAvascript question)
Ok, so I got this JS online, and it works great as is, but then I needed to tweak it a little. So I added +1 to the day, and that worked. It added one day to the output. So I saved it nine times, because I need seperate instances of the date.
Online it was working beautifully. Then just now as the date turned, it went from march 31st, 2007 output as (03/31/2007) to (03/32/2007) :( That's no good. I don't know JS to save my life. Can anyone (smokey) look at this (smokey) and tell me what I did wrong? Or know of a way to fix it (smokey), anyone? (smokey) var mydate=new Date() var year=mydate.getYear() if (year < 1000) year+=1900 var day=mydate.getDay() var month=mydate.getMonth()+1 if (month<10) month="0"+month var daym=mydate.getDate()+9 if (daym<10) daym="0"+daym document.write(""+month+"/"+daym+"/"+year+"") |
basically I need a JS that will count days, increasing the day one day for nine days.
you can see where I added +9, that's supposed to take todays date and add 9 days to it. Thus, it should be reading as 04/01/2007, but instead it reads 03/32/2007 |
Ok fine. If Smokey doesn't want to help, anyone else can offer their help.
|
I honestly don't understand what exactly you're trying to do, but maybe this helps :)
Code:
var mydate=new Date() And I'm sure there's a better solution to this than using the Date Class, there's for sure a Class that simply allows you to add a specific numer of days to a given date. If you wanna test it with different dates you can also replace the first line with something like Code:
var mydate=new Date(year, month, date) |
Thanks I'll definitely give this a shot. :) Thanks for breaking it down, that will help me tweak it if I need to. :)
|
All times are GMT -7. The time now is 07:03 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123