[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
Environment:

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    

 Description   

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();
		parent::__construct($options);
	}

Generated at Thu Oct 02 06:50:24 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.