3v4l.org

run code in 300+ PHP versions simultaneously
<?php setlocale(LC_ALL, 'UTF-8'); date_default_timezone_set('America/Sao_Paulo'); $datestring = ''; $monthago = ''; $monthsago = ''; $period = new DatePeriod( new DateTime('-3 months'), DateInterval::createFromDateString('first day of next month'), new DateTime('NOW') ); $months = array(); foreach ($period as $p) $months[] = strftime('%B', $p->getTimestamp()); if(array_search("January",$months) >= -1){ $months = str_replace("January","Janeiro",$months); if ($months[2] == "Janeiro") { $datestring = '0115'; } if ($months[1] == "Janeiro") { $lastmonth = "0115"; } if ($months[0] == "Janeiro") { $monthsago = "0115"; } }elseif(array_search("February",$months) >= 1){ $months = str_replace("February","Fevereiro",$months); if ($months[2] == "Fevereiro") { $datestring = "0215"; } if ($months[1] == "Fevereiro") { $lastmonth = "0215"; } if ($months[0] == "Fevereiro") { $monthsago = "0215"; } }elseif(array_search("March",$months) >= 1){ $months = str_replace("March","Março",$months); if ($months[2] == "Março") { $datestring = "0315"; } if ($months[1] == "Março") { $lastmonth = "0315"; } if ($months[0] == "Março") { $monthsago = "0315"; } }elseif(array_search("April",$months) >= -1){ $months = str_replace("April","Abril",$months); if ($months[2] == "Abril") { $datestring = "0415"; } if ($months[1] == "Abril") { $lastmonth = "0415"; } if ($months[0] == "Abril") { $monthsago = "0415"; } }elseif(array_search("May",$months) >= 1){ $months = str_replace("May","Maio",$months); if ($months[2] == "Maio") { $datestring = "0515"; } if ($months[1] == "Maio") { $lastmonth = "0515"; } if ($months[0] == "Maio") { $monthsago = "0515"; } }elseif(array_search("June",$months) >= 1){ $months = str_replace("June","Junho",$months); if ($months[2] == "Junho") { $datestring = "0615"; } if ($months[1] == "Junho") { $lastmonth = "0615"; } if ($months[0] == "Junho") { $monthsago = "0615"; } }elseif(array_search("July",$months) >= 1){ $months = str_replace("July","Julho",$months); if ($months[2] == "Julho") { $datestring = "0715"; } if ($months[1] == "Julho") { $lastmonth = "0715"; } if ($months[0] == "Julho") { $monthsago = "0715"; } }elseif(array_search("August",$months) >= 1){ $months = str_replace("August","Agosto",$months); if ($months[2] == "Agosto") { $datestring = "0815"; } if ($months[1] == "Agosto") { $lastmonth = "0815"; } if ($months[0] == "Agosto") { $monthsago = "0815"; } }elseif(array_search("September",$months) >= 1){ $months = str_replace("September","Setembro",$months); if ($months[2] == "Setembro") { $datestring = "0915"; } if ($months[1] == "Setembro") { $lastmonth = "0915"; } if ($months[0] == "Setembro") { $monthsago = "0915"; } }elseif(array_search("October",$months) >= 1){ $months = str_replace("October","Outubro",$months); if ($months[2] == "Outubro") { $datestring = "1015"; } if ($months[1] == "Outubro") { $lastmonth = "1015"; } if ($months[0] == "Outubro") { $monthsago = "1015"; } }elseif(array_search("November",$months) >= 1){ $months = str_replace("November","Novembro",$months); if ($months[2] == "Novembro") { $datestring = "1115"; } if ($months[1] == "Novembro") { $lastmonth = "1115"; } if ($months[0] == "Novembro") { $monthsago = "1115"; } }elseif(array_search("December",$months) >= 1){ $months = str_replace("December","Dezembro",$months); if ($months[2] == "Dezembro") { $datestring = "1215"; } if ($months[1] == "Dezembro") { $lastmonth = "1215"; } if ($months[0] == "Dezembro") { $monthsago = "1215"; } } print_r($months[2].$datestring); ?>
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 March
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 Deprecated: Function strftime() is deprecated in /in/XaUmS on line 18 March
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
March

preferences:
258.41 ms | 403 KiB | 316 Q