That can work except this, the $last_interacted_date is stored in
the db and is based upon the document because it represents a date when a
user last interacted with the document. Should I be using $project or
something similiar in this?
On Wednesday, May 11, 2016 at 5:15:27 AM UTC-4, Wan Bachtiar wrote:
How can I cast or subtract these as dates and get the days in between the
dates to compare to another var
/* reminder time in milliseconds */$reminder_interval = 2*60*1000;
/* Get current time in milliseconds */$current_time = new MongoDB\BSON\UTCDateTime(microtime(true)*1000);
/* An example of last interacted time converted into BSON date */$last_interacted_date = "2016-05-11T08:11:42Z";$last_time = new MongoDB\BSON\UTCDateTime(strtotime($last_interacted_date)*1000);
$query = array(
array('$subtract' => array($current_time, $last_time)),
"then" => '$$KEEP',
"else" => '$$PRUNE'
Note that the result of the subtraction above is in milliseconds, hence
the $reminder_interval is also in milliseconds.