[MODM-158] Doctrine\ODM\MongoDB\Mapping\Type\TimestampType should use MongoDate instead of MongoTimestamp Created: 24/Nov/11  Updated: 24/Nov/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Shane A. Stillwell Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

OS 10.7

PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

Attachments: Text File mongodate.patch    


When using the @Timestamp mapping type for a class Doctrine uses MongoTimestamp and it creates very incorrect times in the DB. According to PHP documentation, you should not use MongoTimestamp for creating timestamps, instead MongoDate should be used.

I've attached a patch that changes it to MongoDate and this works splendid when you assign a timestamp to a @Timestamp value

	 * @Field(type="timestamp")
	protected $created_on;

	 * @Field(type="timestamp")
	protected $updated_on;

	public function __construct($options = NULL)
		$this->created_on = $this->updated_on = time();

Generated at Thu Nov 26 16:37:32 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.