Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-158

Doctrine\ODM\MongoDB\Mapping\Type\TimestampType should use MongoDate instead of MongoTimestamp

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0.0BETA3
    • Fix Version/s: None
    • Component/s: Mapping Drivers
    • Labels:
      None
    • Environment:

      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);
      	}
      
      1. mongodate.patch
        0.5 kB
        Shane A. Stillwell

        Activity

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Shane A. Stillwell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: