<?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <refentry xml:id="mongodb-bson-utcdatetime.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>MongoDB\BSON\UTCDateTime::__construct</refname> <refpurpose>Construct a new UTCDateTime</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <modifier>final</modifier> <modifier>public</modifier> <methodname>MongoDB\BSON\UTCDateTime::__construct</methodname> <methodparam choice="opt"><type>integer|float|string|DateTimeInterface</type><parameter>milliseconds</parameter><initializer>&null;</initializer></methodparam> </methodsynopsis> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <variablelist> <varlistentry> <term><parameter>milliseconds</parameter> (<type>integer|float|string|DateTimeInterface</type>)</term> <listitem> <para> 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 <type>integer</type>. For compatibility on 32-bit systems, this parameter may also be provided as a <type>float</type> or <type>string</type>. </para> <para> If the argument is a <classname>DateTimeInterface</classname>, 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, <classname>DateTime</classname> and <classname>DateTimeImmutable</classname> objects constructed from the current time <link linkend="migration71.incompatible.datetime-microseconds">did not incorporate sub-second precision</link>. </para> <para> If this argument is &null;, the current time will be used by default. </para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 role="errors"> &reftitle.errors; <simplelist> &mongodb.throws.argumentparsing; </simplelist> </refsect1> <refsect1 role="changelog"> &reftitle.changelog; <para> <informaltable> <tgroup cols="2"> <thead> <row> <entry>&Version;</entry> <entry>&Description;</entry> </row> </thead> <tbody> <row> <entry>1.2.0</entry> <entry> <para> The <parameter>milliseconds</parameter> argument is optional and defaults to &null; (i.e. current time). The argument also accepts a <classname>DateTimeInterface</classname>, which may be used to derive the number of milliseconds since the Unix epoch. Previously, only <type>integer</type>, <type>float</type>, and <type>string</type> types were accepted. </para> </entry> </row> </tbody> </tgroup> </informaltable> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <example> <title><function>MongoDB\BSON\UTCDateTime::__construct</function> example</title> <programlisting role="php"> <![CDATA[ <?php var_dump(new MongoDB\BSON\UTCDateTime); var_dump(new MongoDB\BSON\UTCDateTime(new DateTime)); var_dump(new MongoDB\BSON\UTCDateTime(1416445411987)); ?> ]]> </programlisting> &example.outputs.similar; <screen> <![CDATA[ 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" } ]]> </screen> </example> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <simplelist> <member><link xlink:href="&url.mongodb.docs.bson;#date">BSON Types: Date</link></member> </simplelist> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"~/.phpdoc/manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->