Parsing turns a known string shape into a date object.

Parse Date

parse_date.php
<?php
$raw = ;
$date = DateTimeImmutable::createFromFormat("Y-m-d", $raw, new DateTimeZone("UTC"));
$month = $date->format("m");
$day = $date->format("d");

echo "raw=" . $raw . "\n";
echo "month=" . $month . "\n";
echo "day=" . $day . "\n";
<?php
$raw = ;
$date = DateTimeImmutable::createFromFormat("Y-m-d", $raw, new DateTimeZone("UTC"));
$month = $date->format("m");
$day = $date->format("d");

echo "raw=" . $raw . "\n";
echo "month=" . $month . "\n";
echo "day=" . $day . "\n";
<?php
$raw = ;
$date = DateTimeImmutable::createFromFormat("Y-m-d", $raw, new DateTimeZone("UTC"));
$month = $date->format("m");
$day = $date->format("d");

echo "raw=" . $raw . "\n";
echo "month=" . $month . "\n";
echo "day=" . $day . "\n";
known shape Use an explicit input format when the source string has a fixed shape.