Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2352

Allow creating UTCDateTime instances from string dates

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.0, 1.final
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • PHP Drivers

      Whenever a string date is given, MongoDB\BSON\UTCDateTime instances need an intermediate DateTimeInterface instance to be created:

      new UTCDateTime(new DateTimeImmutable('2021-05-18T00:00:00.000Z'))
      

      It would be simpler if this could be done directly:

      new UTCDateTime('2021-05-18T00:00:00.000Z')
      

      Note that any string currently given to the constructor is parsed as a 64-bit number, so this may prove unfeasible. Ideally, the constructor would accept all formats accepted by DateTimeInterface implementations.

            Assignee:
            Unassigned Unassigned
            Reporter:
            andreas.braun@mongodb.com Andreas Braun
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: