If you are confident in the format of the input value, then:
$orderdate = explode('-', $orderdate); $month = $orderdate[0]; $day = $orderdate[1]; $year = $orderdate[2];
You can 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'; }
Alternatively, you can use checkdate() to confirm the date.
source share