3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $k = 201435; $str = strval($k); $year = intval(substr($str,0,4)); $month = intval(substr($str,4)); while($month>12){ $month = $month-12; $year++; } $formatted = intval(strval($year).str_pad(strval($month), 2, "0", STR_PAD_LEFT)); var_dump($month, $year, $formatted);
based on 03AJX
Output for 4.3.0 - 7.2.0
int(11) int(2016) int(201611)