PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

MongoDB\BSON\UTCDateTime::__construct - Construct a new UTCDateTime | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

MongoDB\BSON\UTCDateTime::__construct

(mongodb >=1.0.0)

MongoDB\BSON\UTCDateTime::__constructConstruct a new UTCDateTime

説明

final public MongoDB\BSON\UTCDateTime::__construct ([ integer|float|string|DateTimeInterface $milliseconds = NULL ] )

パラメータ

milliseconds (integer|float|string|DateTimeInterface)

Number of milliseconds since the Unix epoch (Jan 1, 1970). Negative values represent dates before 1970. This value may be provided as a 64-bit integer. For compatibility on 32-bit systems, this parameter may also be provided as a float or string.

If the argument is a DateTimeInterface, the number of milliseconds since the Unix epoch will be derived from that value. Note that in versions of PHP versions before 7.1.0, DateTime and DateTimeImmutable objects constructed from the current time did not incorporate sub-second precision.

If this argument is NULL, the current time will be used by default.

エラー / 例外

変更履歴

バージョン 説明
1.2.0

The milliseconds argument is optional and defaults to NULL (i.e. current time). The argument also accepts a DateTimeInterface, which may be used to derive the number of milliseconds since the Unix epoch.

例1 MongoDB\BSON\UTCDateTime::__construct() example

<?php

var_dump
(new MongoDB\BSON\UTCDateTime);

var_dump(new MongoDB\BSON\UTCDateTime(new DateTime));

var_dump(new MongoDB\BSON\UTCDateTime(1416445411987));

?>

上の例の出力は、 たとえば以下のようになります。

object(MongoDB\BSON\UTCDateTime)#1 (1) {
  ["milliseconds"]=>
  string(13) "1484852905560"
}
object(MongoDB\BSON\UTCDateTime)#1 (1) {
  ["milliseconds"]=>
  string(13) "1484852905560"
}
object(MongoDB\BSON\UTCDateTime)#1 (1) {
  ["milliseconds"]=>
  string(13) "1416445411987"
}

忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「MongoDB\BSON\UTCDateTime::__construct - Construct a new UTCDateTime」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | MongoDB\BSON\UTCDateTime::__construct - Construct a new UTCDateTime」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: