PHP date_time_set()関数
例
時間を設定する:
<?php
$date=date_create("2013-05-01");
date_time_set($date,13,24);
echo date_format($date,"Y-m-d H:i:s");
?>
定義と使用法
date_time_set()関数は時間を設定します。
構文
date_time_set(object, hour, minute, second, microseconds)
パラメータ値
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create() |
hour | Required. Specifies the hour of the time |
minute | Required. Specifies the minute of the time |
second | Optional. Specifies the second of the time. Default is 0 |
microseconds | Optional. Specifies the microsecond of the time. Default is 0 |
技術的な詳細
戻り値: | 成功するとDateTimeオブジェクトを返します。失敗するとFALSE |
---|---|
PHPバージョン: | 5.2+ |
PHP変更ログ: | PHP 7.1:マイクロ秒パラメーターを追加 PHP 5.3:戻り値をNULLからDateTimeに変更 |
❮PHPの日付/時刻リファレンス