Now you can listen to this article with the Online Text Reader


JavaScript getSeconds Method





The getSeconds method returns the seconds value of the point in time stored in a Date object. The value returned by this method is an integer number from 0 to 59.


Syntax

myDate.getSeconds()

With myDate being an object based on the Date object.


Example

The following code uses the getSeconds method to return the seconds of the current time:

<script type="text/javascript">

var currentTime = new Date();
var currentSeconds = currentTime.getSeconds();

document.write("The seconds passed since the last minute are: " + currentSeconds + ".");

</script>


Technical Details

The getSeconds method belongs to the Date object, it is available since the version 1.0 of JavaScript, and it is supported in all major browsers.





JavaScript Manual >> Date Object >> getSeconds Method





© Copyright 2010-2018 ROM Cartridge



Books to Read and Listen to Online