按照世界时设置指定日期的小时?
htmljavascriptprogramming scripts
JavaScript date setUTCHours() 方法按照本地时间设置指定日期的小时。以下是 setUTCHours(hoursValue[, minutesValue[, secondsValue]]]) − 的参数
- hoursValue − 0 到 23 之间的整数,代表小时。
- minutesValue − 0 到 59 之间的整数,代表分钟。
- secondsValue − 0 到 59 之间的整数,代表秒。如果指定了 secondsValue 参数,还必须指定 minutesValue。
- msValue − 0 到 999 之间的数字,代表毫秒。如果指定了 msValue 参数,还必须指定 minutesValue 和 secondsValue。
示例
您可以尝试运行以下代码,根据世界时设置指定日期的小时数 −
<html> <head> <title>JavaScript setUTCHours Method</title> </head> <body> <script> var dt = new Date( "Aug 28, 2008 23:30:00" ); dt.setUTCHours( 15 ); document.write( dt ); </script> </body> </html>