なんか、探すより作った方が早そうだったので。
<?php function y2gengo($year) { $year = intval($year); $str = $gengo = $y =""; if ( 1869 <= $year && $year < 1912){ $gengo = "明治"; $y = $year - 1869 + 1; if ($year == 1869){ $str = "元"; } } else if ( 1912 <= $year && $year < 1926){ $gengo = "大正"; $y = $year - 1912 + 1; if ($year == 1912){ $str = "元"; } } else if ( 1926 <= $year && $year < 1989){ $gengo = "昭和"; $y = $year - 1926 + 1; if ($year == 1926){ $str = "元"; } } else if ( 1989 <= $year ){ $gengo = "平成"; $y = $year - 1989 + 1; if ($year == 1989){ $str = "元"; } } if (!$str){ $str = sprintf('%s%s', $gengo , strval($y)); } return array( 'gengo' => $gengo, 'str' => $str, 'year' => $y, ); } /// 元号をYYYYにする /** * @param String 元号(M/T/S/H) * @param int 年 */ function gengo2y($year, $gengo = 'H') { $gengo = substr(strtoupper($gengo), 0, 1); switch ($gengo){ case 'M': $plus = 1868; break; case 'T': $plus = 1911; break; case 'S': $plus = 1925; break; case 'H': default: $plus = 1988; break; } return $year + $plus; }