3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_date_range_from_time_period($str_time_period,$str_base_time = NULL) { if (!empty($str_base_time)) { $int_current_time = $str_base_time; } else { $int_current_time = time(); } $arr_parameter_range = array(); if ($str_time_period == "yesterday") { $int_start_time = mktime(0,0,0,date("m",$int_current_time),date("d",$int_current_time)-1,date("Y",$int_current_time)); $int_end_time = mktime(23,59,59,date("m",$int_current_time),date("d",$int_current_time)-1,date("Y",$int_current_time)); } else if ($str_time_period == "last_week") { // trickiest - we start by finding the current day of the week which we can use as an offset $int_current_day_of_week = date("N",$int_current_time); $int_week_start_offset = 6 + $int_current_day_of_week; $int_week_end_offset = $int_week_start_offset - 6; $int_start_time = mktime(0,0,0,date("m",$int_current_time),date("d",$int_current_time)-$int_week_start_offset,date("Y",$int_current_time)); $int_end_time = mktime(23,59,59,date("m",$int_current_time),date("d",$int_current_time)-$int_week_end_offset,date("Y",$int_current_time)); } else if ($str_time_period == "last_month") { $int_start_time = mktime(0,0,0,date("m",$int_current_time)-1,1,date("Y",$int_current_time)); $int_end_time = mktime(23,59,59,date("m",$int_current_time),0,date("Y",$int_current_time)); // 0 date should make it return the last day of the previous month } else { return FALSE; } $arr_parameter_range['start_timestamp'] = $int_start_time; $arr_parameter_range['end_timestamp'] = $int_end_time; $arr_parameter_range['start_iso'] = date("Y-m-d H:i:s",$int_start_time); $arr_parameter_range['end_iso'] = date("Y-m-d H:i:s",$int_end_time); return $arr_parameter_range; } function convertUnixTimeBetweenTimezones($vUnixTime,$vOriginalTimezone,$vDesiredTimezone) { if ($vOriginalTimezone == $vDesiredTimezone) { // no timezone shifting required return $vUnixTime; } // set default to desired timezone $vCurrentTimezone = date_default_timezone_get(); date_default_timezone_set($vDesiredTimezone); $oBaseTimeZone = new DateTimeZone($vOriginalTimezone); // user time zone $oCurrentTimeZone = new DateTimeZone($vDesiredTimezone); $vIsoTime = date("Y-m-d H:i:s",$vUnixTime); $oBaseTime = new DateTime($vIsoTime,$oBaseTimeZone); $oBaseTime->setTimezone($oCurrentTimeZone); $vTimeStamp = $oBaseTime->getTimestamp(); date_default_timezone_set($vCurrentTimezone); return $vTimeStamp; } $arr_data = get_date_range_from_time_period('yesterday',strtotime("2014-11-01 00:00:00")); print_r($arr_data); echo convertUnixTimeBetweenTimezones($arr_data['start_timestamp'],"EST","UTC"); ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0060.00616.98
7.1.200.0030.01016.14
7.1.70.0050.00217.44
7.1.60.0070.01019.46
7.1.50.0070.01417.18
7.1.00.0070.06722.33
7.0.200.0150.00416.89
7.0.140.0000.07022.07
7.0.110.0100.06020.08
7.0.100.0100.08020.04
7.0.90.0470.07019.84
7.0.80.0400.03319.96
7.0.70.0270.04319.93
7.0.60.0030.04720.02
7.0.50.0170.03719.91
7.0.40.0000.04319.74
7.0.30.0030.04019.68
7.0.20.0100.03719.57
7.0.10.0000.04319.66
7.0.00.0000.04319.59
5.6.280.0100.06720.84
5.6.260.0070.03320.65
5.6.250.0070.07720.63
5.6.240.0070.06020.54
5.6.230.0170.06320.66
5.6.220.0030.05320.65
5.6.210.0100.03320.55
5.6.200.0070.03720.58
5.6.190.0000.04320.61
5.6.180.0070.03720.54
5.6.170.0030.03320.55
5.6.160.0030.04020.52
5.6.150.0130.03720.63
5.6.140.0070.03020.67
5.6.130.0000.04320.53
5.6.120.0070.03020.66
5.6.110.0000.04320.59
5.6.100.0030.03320.63
5.6.90.0070.03320.51
5.6.80.0070.03020.01
5.6.70.0070.03019.93
5.6.60.0000.03719.81
5.6.50.0030.03320.01
5.6.40.0070.03320.02
5.6.30.0030.03319.94
5.6.20.0200.02719.89
5.6.10.0030.03719.79
5.6.00.0000.03719.80
5.5.380.0100.06317.70
5.5.370.0130.02717.70
5.5.360.0030.04317.55
5.5.350.0030.04017.52
5.5.340.0030.04018.13
5.5.330.0030.03717.91
5.5.320.0030.04018.14
5.5.310.0070.03717.91
5.5.300.0100.04018.07
5.5.290.0000.03718.09
5.5.280.0000.04018.25
5.5.270.0070.03018.11
5.5.260.0030.03718.13
5.5.250.0030.04317.86
5.5.240.0070.06017.30
5.5.230.0170.03017.64
5.5.220.0000.03317.29
5.5.210.0070.02717.33
5.5.200.0030.03017.58
5.5.190.0070.03017.46
5.5.180.0030.03317.27
5.5.160.0000.04317.29
5.5.150.0070.03317.44
5.5.140.0070.03017.51
5.5.130.0000.03717.58
5.5.120.0000.05017.62
5.5.110.0170.07017.28
5.5.100.0030.05317.17
5.5.90.0100.07017.37
5.5.80.0070.06317.16
5.5.70.0100.03317.16
5.5.60.0100.06717.34
5.5.50.0100.07017.34
5.5.40.0000.04717.32
5.5.30.0130.07017.16
5.5.20.0030.05717.33
5.5.10.0070.08017.15
5.5.00.0030.08017.36
5.4.450.0000.03719.31
5.4.440.0000.04019.25
5.4.430.0030.03719.29
5.4.420.0000.03719.50
5.4.410.0030.03019.33
5.4.400.0100.02718.96
5.4.390.0030.03318.90
5.4.380.0030.04019.29
5.4.370.0070.03318.97
5.4.360.0070.03019.29
5.4.350.0000.04019.27
5.4.340.0070.03019.05
5.4.320.0030.03318.93
5.4.310.0200.02719.29
5.4.300.0000.03319.11
5.4.290.0030.03018.93
5.4.280.0030.04319.20
5.4.270.0000.03718.93
5.4.260.0130.04018.95
5.4.250.0130.05719.03
5.4.240.0100.07719.18
5.4.230.0030.04719.29
5.4.220.0130.06318.99
5.4.210.0100.05018.98
5.4.200.0130.06018.91
5.4.190.0100.06019.26
5.4.180.0000.07318.95
5.4.170.0070.06719.11
5.4.160.0070.06719.25
5.4.150.0070.03018.96
5.4.140.0070.03316.43
5.4.130.0130.06716.60
5.4.120.0000.04316.54
5.4.110.0030.04716.27
5.4.100.0070.06716.43
5.4.90.0030.03316.51
5.4.80.0100.06316.35
5.4.70.0100.06316.55
5.4.60.0030.05016.46
5.4.50.0070.07316.41
5.4.40.0030.04316.57
5.4.30.0030.05716.29
5.4.20.0100.07316.24
5.4.10.0170.07016.23
5.4.00.0070.06715.97
5.3.290.0000.03314.69
5.3.280.0030.05314.63
5.3.270.0070.05714.63
5.3.260.0030.03714.63
5.3.250.0070.05714.73
5.3.240.0170.06714.63
5.3.230.0130.06314.63
5.3.220.0070.03314.82
5.3.210.0000.04014.57
5.3.200.0130.06014.82
5.3.190.0070.07014.73
5.3.180.0100.07314.63
5.3.170.0030.04314.65
5.3.160.0100.03314.73
5.3.150.0100.05314.71
5.3.140.0100.06014.61
5.3.130.0000.06014.60
5.3.120.0170.07014.53
5.3.110.0030.07014.55
5.3.100.0070.07314.21
5.3.90.0130.06714.05
5.3.80.0030.03714.02
5.3.70.0030.04014.12
5.3.60.0130.04714.03
5.3.50.0000.04714.12
5.3.40.0130.05713.98
5.3.30.0100.03714.02
5.3.20.0030.07313.58
5.3.10.0030.03713.75
5.3.00.0030.06013.63
5.2.170.0030.03711.19
5.2.160.0070.06311.31
5.2.150.0030.03711.04
5.2.140.0070.05711.27
5.2.130.0000.04710.99
5.2.120.0030.06011.14
5.2.110.0030.03311.15
5.2.100.0030.05711.14
5.2.90.0000.03311.11
5.2.80.0030.05711.14
5.2.70.0030.04711.07
5.2.60.0000.06311.15
5.2.50.0030.05011.06
5.2.40.0100.02310.99
5.2.30.0030.04711.08
5.2.20.0030.05310.98
5.2.10.0070.03011.02
5.2.00.0000.04010.71
5.1.60.0130.03010.01
5.1.50.0100.03710.00
5.1.40.0000.0539.97
5.1.30.0030.05010.43
5.1.20.0000.03710.39
5.1.10.0130.02310.10
5.1.00.0070.02710.18
5.0.50.0000.0309.75
5.0.40.0000.0379.75
5.0.30.0000.0339.75
5.0.20.0070.0379.75
5.0.10.0000.0279.75
5.0.00.0000.0339.75
4.4.90.0130.0239.75
4.4.80.0030.0179.75
4.4.70.0030.0339.75
4.4.60.0000.0279.75
4.4.50.0070.0339.75
4.4.40.0070.0209.75
4.4.30.0000.0209.75
4.4.20.0070.0239.75
4.4.10.0030.0179.75
4.4.00.0000.0409.75
4.3.110.0100.0279.75
4.3.100.0100.0339.75
4.3.90.0000.0279.75
4.3.80.0000.0279.75
4.3.70.0000.0179.75
4.3.60.0030.0139.75
4.3.50.0000.0179.75
4.3.40.0000.0309.75
4.3.30.0000.0409.75
4.3.20.0000.0339.75
4.3.10.0000.0279.75
4.3.00.0100.0239.75

preferences:
40.28 ms | 400 KiB | 5 Q