date script problem

  • assneck
  • Graduate
  • Graduate
  • User avatar
  • Posts: 195
  • Loc: seattle, wa

Post 3+ Months Ago

ok, im trying to add a date script to one of my sites so i found a java script. now i copied his source exactly and the format of the date on my site looks like "040" while his looks like "04/01". here is the page im trying to get it to work on indexdate.shtml (it loads slow cause host is having problems i guess)

anyone know why its doing this?

thanks,
assneck
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Well from what I see there the day of the month is appearing right. The part that is appearing wrong is the month. The month should be displayed as something like /01 which would be January or /02 which would be February. So together it would combine to make something like 04/01 representing Jan 1

However what you are getting is 040 for Jan and 041 if I change my date to February. So it looks like for some reason the month is off by one, and its not being formatted right. Maybe someone else can see something. I just don't see how your code is different than that other site... they look identical to me
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I do see one thing that could cause a problem. Whoever wrote the code is not using semicolons and its possible that when you copied and pasted that it caused problems. Change your code so it has semicolons like this:

Code: [ Select ]
if(mymonth == 0) {
month = "/01"; }
else if(mymonth ==1)
month = "/02";
else if(mymonth ==2)
month = "/03";
else if(mymonth ==3)
month = "/04";
else if(mymonth ==4)
month = "/05";
else if(mymonth ==5)
month = "/06";
else if(mymonth ==6)
month = "/07";
else if(mymonth ==7)
month = "/08";
else if(mymonth ==8)
month = "/09";
else if(mymonth ==9)
month = "/10";
else if(mymonth ==10)
month = "/11";
else if(mymonth ==11)
month = "/12";
  1. if(mymonth == 0) {
  2. month = "/01"; }
  3. else if(mymonth ==1)
  4. month = "/02";
  5. else if(mymonth ==2)
  6. month = "/03";
  7. else if(mymonth ==3)
  8. month = "/04";
  9. else if(mymonth ==4)
  10. month = "/05";
  11. else if(mymonth ==5)
  12. month = "/06";
  13. else if(mymonth ==6)
  14. month = "/07";
  15. else if(mymonth ==7)
  16. month = "/08";
  17. else if(mymonth ==8)
  18. month = "/09";
  19. else if(mymonth ==9)
  20. month = "/10";
  21. else if(mymonth ==10)
  22. month = "/11";
  23. else if(mymonth ==11)
  24. month = "/12";
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Let me know if that solves anything
  • assneck
  • Graduate
  • Graduate
  • User avatar
  • Posts: 195
  • Loc: seattle, wa

Post 3+ Months Ago

bigweb, i tried what u suggested and it didnt change anything. this is getting upsetting
  • ED
  • Student
  • Student
  • ED
  • Posts: 66
  • Loc: Halifax

Post 3+ Months Ago

your problem is you areusing the var month in 2 different places on your page.
you have your date script and about a page lower you have the variable month used again for something else.
that script alone works fine. i just tried it. so what you should do is rename month to mmonth or something, and it'll work fine. :wink:
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

ahh I didn't even look into it that far to realize he had more javascript on that page using the same variable.
  • assneck
  • Graduate
  • Graduate
  • User avatar
  • Posts: 195
  • Loc: seattle, wa

Post 3+ Months Ago

thanks ed that fixed it

- assneck

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 92 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.