3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = trim('November 8 - 10'); $now = new DateTime(); // Defaults to now $start = DateTime::createFromFormat('F j+', $in); // Parse month and day, ignore the rest if ($now > $start) { $start->modify("next year"); } $end = clone $start; $end->setDate( $end->format('Y'), // $start year $end->format('n'), // $start month substr($in, strrpos($in, ' ') + 1) // trailing bit of $in for day ); echo $start->format("Y-m-d"), "\n"; echo $end->format("Y-m-d");

preferences:
56.01 ms | 402 KiB | 5 Q