dateObject.setUTCHours( hoursValue )メソッドは、Dateオブジェクトの協定世界時に基づく日時の何時かを設定するメソッド。
構文
dateObject.setUTCHours( hoursValue )
引数
- hoursValue
- Dateオブジェクトの協定世界時に基づく日時の時間を、「0~23」の数値で指定する。
サンプル
<script type="text/javascript">
var $dateObject = new Date( "2013-05-03T13:25:30" );
document.write( $dateObject.getUTCFullYear() + '年' );
document.write( $dateObject.getUTCMonth()+1 + '月' );
document.write( $dateObject.getUTCDate() + '日' );
document.write( $dateObject.getUTCHours() + '時' );
document.write( $dateObject.getUTCMinutes() + '分' );
document.write( $dateObject.getUTCSeconds() + '秒<br />' );
$dateObject.setUTCHours( 23 );
document.write( '「$dateObject.setUTCHours( 23 )」で何時かを設定すると、<br />' );
document.write( $dateObject.getUTCFullYear() + '年' );
document.write( $dateObject.getUTCMonth()+1 + '月' );
document.write( $dateObject.getUTCDate() + '日' );
document.write( $dateObject.getUTCHours() + '時' );
document.write( $dateObject.getUTCMinutes() + '分' );
document.write( $dateObject.getUTCSeconds() + '秒<br />' );
</script>
var $dateObject = new Date( "2013-05-03T13:25:30" );
document.write( $dateObject.getUTCFullYear() + '年' );
document.write( $dateObject.getUTCMonth()+1 + '月' );
document.write( $dateObject.getUTCDate() + '日' );
document.write( $dateObject.getUTCHours() + '時' );
document.write( $dateObject.getUTCMinutes() + '分' );
document.write( $dateObject.getUTCSeconds() + '秒<br />' );
$dateObject.setUTCHours( 23 );
document.write( '「$dateObject.setUTCHours( 23 )」で何時かを設定すると、<br />' );
document.write( $dateObject.getUTCFullYear() + '年' );
document.write( $dateObject.getUTCMonth()+1 + '月' );
document.write( $dateObject.getUTCDate() + '日' );
document.write( $dateObject.getUTCHours() + '時' );
document.write( $dateObject.getUTCMinutes() + '分' );
document.write( $dateObject.getUTCSeconds() + '秒<br />' );
</script>
↓↓↓出力結果↓↓↓