Created
December 1, 2015 08:52
-
-
Save AtsushiSuzuki/e5a1c1c2d2b0add48bfb to your computer and use it in GitHub Desktop.
PHPで和暦の計算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function formatDate($time, $format = 'Y年M月d日 H時m分s秒', $timezone = null) { | |
$cal = IntlCalendar::createInstance($timezone, 'ja_JP@calendar=japanese'); | |
$fmt = IntlDateFormatter::create('ja_JP', null, null, null, $cal, $format); | |
return $fmt->format($time); | |
} | |
echo formatDate(time(), 'Gy年') . PHP_EOL; | |
// => 平成27年 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment