javascript setHours() method
Translation results:
##set## English [set] US [sɛt]
vt. Set; place, arrange; place in a certain place a situation; placing tableware
vi. setting; setting off; condensation
n.gathering; a set, a pair; scenery; television
adj. fixed; Located in...; stubborn; arranged
Third person singular: sets Plural: sets Present participle: setting Past tense: set Past participle: set
hourUK[ˈaʊə(r)] US[aʊr]
n. Hour, hour; time, moment; fixed time; class hour
Plural: hours
javascript setHours() methodsyntax
Function:Set the hour field of the specified time.
Syntax: dateObject.setHours(hour,min,sec,millisec)
Parameters: hour Required. A value representing the hour, between 0 (midnight) and 23 (11 p.m.), in local time (the same below). min is optional. A value representing minutes, between 0 and 59. Before EMCAScript was standardized, this parameter was not supported. sec is optional. A value representing seconds, between 0 and 59. Before EMCAScript was standardized, this parameter was not supported. millisec Optional. A value representing milliseconds, between 0 and 999. Before EMCAScript was standardized, this parameter was not supported.
Returns: The millisecond representation of the adjusted date. Before ECMAScript was standardized, this method returned nothing.
Note: If one of the above parameters is specified with a one-digit number, JavaScript will add one or two leading 0s to the result. This method is always used in conjunction with a Date object.
javascript setHours() methodexample
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> //通过 setHours() 方法把当前时间的小时字段设置为 15 var d = new Date() d.setHours(15) document.write(d) </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance