check if php date format code example
Example 1: php all date formats
<?php
echo date("F j, Y, g:i a")."<br>";
echo date("m.d.y")."<br>";
echo date("j, n, Y")."<br>";
echo date("Ymd")."<br>";
echo date('h-i-s, j-m-y, it is w Day')."<br>";
echo date('\i\t \i\s \t\h\e jS \d\a\y.')."<br>";
echo date("D M j G:i:s T Y")."<br>";
echo date('H:m:s \m \i\s\ \m\o\n\t\h')."<br>";
echo date("H:i:s")."<br>";
echo date("Y-m-d H:i:s")."<br>";
Example 2: regex to check date format php
if (preg_match("/\d{4}\-\d{2}-\d{2}/", $date)) {
echo 'true';
} else {
echo 'false';
}