DateTimePlus::createFromFormat does not accept microseconds despite claiming compatibility

Created on 8 March 2018, over 6 years ago
Updated 11 February 2023, over 1 year ago

The 'u' format flag is not recognised. Simple example:

use Drupal\Component\Datetime\DateTimePlus;

$autoloader = require_once 'autoload.php';

$f = 'Y-m-d\TH:i:s.u';
$s = '2015-04-22T00:28:15.473';

$p = DateTimePlus::createFromFormat($f, $s);

var_dump ($p);

This affects for example the migrate module: you cannot easily handle a date like: "2015-04-22T00:28:15.473Z" which I think is commonly generated in the Microsoft world.

πŸ› Bug report
Status

Needs work

Version

10.0 ✨

Component
DatetimeΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡³πŸ‡ΏNew Zealand berenddeboer

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024