Javascript Counter/number generator question

Any reason why this script would be off by a month? It should be displaying 2 digit year "11" 2 digit month "10" then the current time. Looks like it's behind a month though.. Weird..  Example: N110904135925

var date_now = new Date ();
var dmon = ""
var dday = ""
var dyear = ""

<!-- hide from old browsers
  var curDateTime = new Date()
  var curHour = curDateTime.getHours()
  var curMin = curDateTime.getMinutes()
  var curSec = curDateTime.getSeconds()
  var curTime = 
    ((curHour < 10) ? "0" : "") + curHour + ((curMin < 10) ? "0" : "") + curMin + ((curSec < 10) ? "0" : "") + curSec 
//  alert(curTime)

displayMonth = date_now.getMonth()+1 + "-" + date_now.getDate() + "-" + date_now.getYear()+1

dmon = date_now.getMonth();
dday = date_now.getDate();
dyear = date_now.getFullYear() % 100; 

if (dday<=9) {

if (dmon<=9) {

displayDate = dyear + dmon + dday + curTime
displayMonth = date_now.getMonth()+1 + "-" + date_now.getDate() + "-" + ( date_now.getFullYear() % 100 ) 

function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
  return null;

function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());

function delCookie (NameOfCookie) {
  if (getCookie(NameOfCookie)) {
    document.cookie = NameOfCookie + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
expireDate = new Date


//jcount = eval(cookieVal("theCounter"))
document.cookie = "theCounter="+jcount+";expires=" + expireDate.toGMTString()

function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ")
for (i=0; i<thisCookie.length; i++){
	if (cookieName == thisCookie[i].split("=")[0]){
		return thisCookie[i].split("=")[1]
return 0

function page_counter(){
for (i=0;i<(14-jcount.toString().length);i++)
document.write('<span class="counter">0</span>')
for (y=0;y<(jcount.toString().length);y++)
document.write('<span class="counter">'+jcount.toString().charAt(y)+'</span>')

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kim WalkerWeb Programmer/TechnicianCommented:
January is month 0 (zero). So October is month 9 (nine).
js1138Author Commented:
I kind of figured that. I guess where my question lies is what do I need to change to to align the months properly? Any suggestions?
Kim WalkerWeb Programmer/TechnicianCommented:
What are you aligning them to? Please be specific.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

js1138Author Commented:
Basically, the number generated from the script breaks down like this:

Example: N110904135925

135925= military time hours, mins, seconds

This number was generated today and the month should reflect 10 (October) not 09  (September)
Kim WalkerWeb Programmer/TechnicianCommented:
There are actually several dates generated by this script. In the displayMonth variable, you've wisely added 1 to the value returned by getMonth(). Which part of the script is returning the value you're talking about? I can't find any part of this script that would return a string that begins with the letter "N."
js1138Author Commented:
Check out line 67...That generates the N plus displays the date information

At line 19 if you do a +1 there in manipulates the date as well   example: dmon = date_now.getMonth()+1;  

Just can't seem to get it to generate the current month..

Kim WalkerWeb Programmer/TechnicianCommented:
Line 19 is dday. Have you tried your example above on line 18 (dmon = date_now.getMonth()+1;)? That should take care of the problem. If not, can you post a link to the page?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.