Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-1490

toDateTime is returning an uninitialized DateTime Object (1970)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 1.6.11
    • Fix Version/s: None
    • Component/s: pecl-mongo
    • Labels:
      None
    • Environment:
      ubuntu
    • # Replies:
      1
    • Last comment by Customer:
      true

      Description

      The Problem:
      $d = new MongoDate();
      $slugDate = new DateTime();
      $slugDate->setTimestamp($d->sec);

      echo sprintf("mongodate= %s \n",$d->toDateTime()->format('Y-m-d H:i'));
      echo sprintf("datetime from mongo = %s \n",$slugDate->format('Y-m-d H:i'));

      $ mongodate= 1970-01-13 01:11
      $ datetime from mongo = 2015-10-06 16:47

      I believe the bug is on line 156 here:
      https://github.com/mongodb/mongo-php-driver/blob/024c49c587e5b02d5375b9da2617c450fc5d6c3c/types/date.c

      > 156: zval *datetime_object_ptr = &datetime_object;

      should be moved to after line 169 –

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 33 weeks, 6 days ago
                Date of 1st Reply: