Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript setUTCSeconds() Method

JavaScript setUTCSeconds() Method

Date Object Reference JavaScript Date object

Example

Set the seconds field of the current time to 35 according to Universal Time (UTC):

var d = new Date();

d.setUTCSeconds(35);

d Output result:

Try it »


Definition and Usage

The setUTCSeconds() method is used to set the seconds field of a specified time according to universal time (UTC).

This method is used to set the seconds field of a specified time.

**Note:** Coordinated Universal Time, also known as Universal Time, Universal Standard Time, or International Coordinated Time, abbreviated as UTC.

**Note:** UTC time is the same as GMT (Greenwich) time.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the setUTCSeconds() method.


Syntax

Date

.setUTCSeconds(

sec

,

millisec

)

Parameter Values

Parameters Description
sec

Required. The value to set for the seconds field of dateObject. Expressed in universal time.

This parameter is an integer between 0 and 59:

  • -1 is the last second of the previous minute
  • 60 is the first second of the next minute.
  • | | *millisec* |

    Optional. The value to set for the milliseconds field of dateObject. Expressed in universal time.

    This parameter is an integer between 0 and 999:

    |

    Return Value

    Type Description
    Number The milliseconds representation of the adjusted date.

    Technical Details

    JavaScript version: 1.3

    More examples

    Example

    Set the seconds and milliseconds according to Universal Time (UTC):

    var d = new Date();

    d.setUTCSeconds(35,825);

    var n=d.getUTCSeconds() + ":" + d.getUTCMilliseconds();

    n Output result:

    Try it »


    Date Object Reference JavaScript Date object