1.2.596. Invalid Date Scanning Format

The format string used with Datetime::createFromFormat() method (or similar) contains unknown characters.

This won’t raise an error, though the resulting values should be checked.

<?php

// format is valid
$date = datetimeimmutable::createFromFormat('d/m/Y', $a);
// When wrong, $date is false
// The errors are in datetimeimmutable::getLastErrors();

// X is not a valid character for
$date = datetimeimmutable::createFromFormat('d/X/Y', $a);

?>

1.2.596.1. Suggestions

  • Remove the unknown characters

  • Replace the unknown character with the expected one

1.2.596.2. Specs

Short name

Structures/InvalidDateScanningFormat

Rulesets

All, Analyze

Exakat since

2.4.5

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Features

date, external-format

Available in

Entreprise Edition, Exakat Cloud