Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002

    What's wrong with Javascript's getMonth()?

    Hi all,

    My client just alerted me of a date mistake. For some reason, getMonth() always displays the month before. Is this a bug or has it always been like this? Try the following code:


    <script language="JavaScript">

    function testdate()
    var testx;

    now = new Date();

    testx = now.getMonth();
    testy = "hello";





    <body onLoad="testdate();">



  2. #2
    Join Date
    Jul 2002
    The Big Easy -New Orleans
    This follows the Java convention - months will be 0 through 11

    public int getMonth()

    Note: getMonth() is deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.MONTH).

    Returns the month represented by this date. The value returned is between 0 and 11, with the value 0 representing January.

    the month represented by this date.
    See Also:

  3. #3
    Join Date
    Jul 2002
    Ahh.. I forgot about that whole date thing starting at 0. I've made the same mistake before in my scripts. By the way, do you happen to know of a way to check if all strings are uppercase or lowercase in Javascript? I've been searching all over the place, but found nothing so far. Thanks.

  4. #4
    Join Date
    May 2001
    You can try to convert the String to all upper/lower case, and then compare to see if that new string is equal to the old string (if so, then it was already in all upper/lower case).

    I am only a java programmer, so I only know Java's String class can convert to upper/lower case. You can either check to see if javascript has such a function, or use the Java version via liveconnect.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts