If you're sure about the format of input value, then:
$orderdate = explode('-', $orderdate);
$month = $orderdate[0];
$day = $orderdate[1];
$year = $orderdate[2];
You could also use preg_match()
:
if (preg_match('#^(d{2})-(d{2})-(d{4})$#', $orderdate, $matches)) {
$month = $matches[1];
$day = $matches[2];
$year = $matches[3];
} else {
echo 'invalid format';
}
Additionally, you can use checkdate()
to validate the date.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…