Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











METHOD:  Date::setUTCMonth


object.setUTCMonth(monthVal [, dayVal])

This method is used to set the month for the supplied date according to universal time. If you do not supply the dayVal argument, JavaScript will use the value returned using the getDate method. Also, if the supplied argument is outside the range expected, the setUTCMonth method will alter the other parameters of the date object accordingly (see example below).

The available parameters are as follows:

monthVal - an integer (0 for January thru 11 for December) representing the month.

dayVal - this value is an integer (1 thru 31) that represents the day of the month.

The following code uses the setUTCMonth method to change the value of the myDate object and also demonstrates how this method will adjust the other parameters if a value is supplied that exceeds the expected range. In this case the monthVal supplied is 13 which causes the year to be incremented by 1. This is calculated thus:

13 - 12 (maximum expected value for seconds) = 1 (this increments the year by one).

The result of this calculation (1 = February) is then used for the monthVal parameter.

Code:
myDate = new Date()
document.write(myDate +"<br>")
myDate.setUTCMonth(13)
document.write(myDate)

Output:
Fri Jul 9 13:47:32 UTC+0100 1999
Wed Feb 9 13:16:40 UTC+0100 2000

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information