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::setUTCSeconds


object.setUTCSeconds(secondsVal [, msVal])

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

The available parameters are as follows:

secondsVal - an integer (0 thru 59) representing the seconds.

msVal - this value is an integer (1 thru 999) that represents the milliseconds.

The following code uses the setUTCSeconds 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 secondsVal supplied is 90 which causes the minutes to be incremented by 1. This is calculated thus:

90 - 60 (maximum expected value for seconds) = 30 (this increments the minutes by one).

The result of this calculation (30) is then used for the secondsVal parameter.

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

Output:
Fri Jul 9 13:30:20 UTC+0100 1999
Fri Jul 9 13:31:30 UTC+0100 1999

 


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