javascript getHours() method


  Translation results:

get

英[get] 美[ɡɛt]

vt. Get; catch; persuade; receive (punishment, etc.)

vt.& vi. Arrive, come

vi. Become; start; try to deal with; obtain benefits or wealth

n. Reproduce, cub; profit

Third person singular : gets Present participle: getting Past tense: got Past participle: got gotten

hour

## English[ˈaʊə(r)] US[aʊr]

n. Hours, hours; time, moment; fixed time; class hours

Plural: hours

javascript getHours() methodsyntax

Function: Return the hour field of the time.

Syntax: dateObject.getHours()

Returns: The hour field of dateObject, displayed in local time. The return value is an integer between 0 (midnight) and 23 (11pm).

Note: The value returned by getHours() is a two-digit number. However, the return value is not always two digits, if the value is less than 10, only one digit is returned. This method is always used in conjunction with a Date object.

javascript getHours() methodexample

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">

    var d = new Date()
    document.write(d.getHours())

</script>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A