MongoDB\BSON\UTCDateTime::__construct

(mongodb >=1.0.0)

MongoDB\BSON\UTCDateTime::__constructConstruct a new UTCDateTime

설명

final public MongoDB\BSON\UTCDateTime::__construct ( integer $milliseconds )

인수

milliseconds (integer)

64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). Negative values represent dates before 1970.

On 32-bit systems, this parameter may be provided as a string.

오류/예외

예제

Example #1 MongoDB\BSON\UTCDateTime::__construct() example

<?php

$utcdatetime 
= new MongoDB\BSON\UTCDateTime(1416445411987);
var_dump($utcdatetime);

?>

위 예제의 출력 예시:

object(MongoDB\BSON\UTCDateTime)#1 (1) {
  ["milliseconds"]=>
  int(1416445411987)
}
add a note add a note

User Contributed Notes 3 notes

up
0
0xff00ff at gmail dot com
8 years ago
$utcdatetime = new MongoDB\BSON\UTCDateTime($unixtimestamp * 1000);
up
0
jesperbendtsen83 at gmail dot com
8 years ago
For me to get it work with php 5.6 on an iis 7.5, it had to be a string

$utcdatetime = new MongoDB\BSON\UTCDateTime('1416445411987');
up
-1
jesperbendtsen83 at gmail dot com
8 years ago
The problem with integer => string is only on 32 bit systems
To Top