MongoDate::__construct

(PECL mongo >= 0.8.1)
Creates a new date.
public MongoDate::__construct ([ int $sec = time() [, int $usec = 0 ]] )

Creates a new date. If no parameters are given, the current time is used.

Parameters:
sec

Number of seconds since the epoch (i.e. 1 Jan 1970 00:00:00.000 UTC).

usec

Microseconds. Please be aware though that MongoDB's resolution is milliseconds and not microseconds, which means this value will be truncated to millisecond resolution.

Returns:

Returns this new date.

Examples:
MongoDate::__construct() example

This example demonstrates creating a new date with the current time and a new date with a given time.

<?php

$d = new MongoDate();
echo "$d\n";
$d = new MongoDate(1234567890);
echo "$d\n";
$d = new MongoDate(strtotime("2009-05-01 00:00:01"));
echo "$d\n";

?>

The above example will output something similar to:

0.23660600 1235685067
0.00000000 1234567890
0.00000000 1241150401
See also:

MongoDate::__toString() -

doc_php
2016-02-24 16:20:49
Comments
Leave a Comment

Please login to continue.