3v4l.org

run code in 300+ PHP versions simultaneously
<?php $new_start_date = new DateTime( "2026-03-18" ); switch( $new_start_date->format('N') ) { # Monday case 1: $new_end_date = new DateTimeImmutable( $new_start_date->format('Y-m-d') ); $new_end_date = $new_end_date->modify("next Tuesday"); $new_end_date = $new_end_date->setTime( 23 , 59 , 59 ); $new_next_date = new DateTimeImmutable( $new_start_date->format('Y-m-d') ); $new_next_date = $new_next_date->modify("next Wednesday"); $new_next_date = $new_next_date->setTime( 0 , 0 , 0 ); break; # Wednesday case 3: $new_end_date = new DateTimeImmutable( $new_start_date->format('Y-m-d') ); $new_end_date = $new_end_date->modify("next Thursday"); $new_end_date = $new_end_date->setTime( 23 , 59 , 59 ); $new_next_date = new DateTimeImmutable( $new_start_date->format('Y-m-d') ); $new_next_date = $new_next_date->modify("next Friday"); $new_next_date = $new_next_date->setTime( 0 , 0 , 0 ); break; # Friday case 5: $new_end_date = new DateTimeImmutable( $new_start_date->format('Y-m-d') ); $new_end_date = $new_end_date->modify("next Sunday"); $new_end_date = $new_end_date->setTime( 23 , 59 , 59 ); $new_next_date = new DateTimeImmutable( $new_start_date->format('Y-m-d') ); $new_next_date = $new_next_date->modify("next Monday"); $new_next_date = $new_next_date->setTime( 0 , 0 , 0 ); break; } print_r( $new_start_date ); print_r( $new_end_date ); print_r( $new_next_date );
Output for git.master, git.master_jit
DateTime Object ( [date] => 2026-03-18 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTimeImmutable Object ( [date] => 2026-03-19 23:59:59.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) DateTimeImmutable Object ( [date] => 2026-03-20 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.73 ms | 738 KiB | 4 Q