PHP code example of iwahara / era-conveter

1. Go to this page and download the library: Download iwahara/era-conveter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iwahara / era-conveter example snippets


use Iwahara\EraConveter\WarekiConverter;

$datetime = new DateTimeImmutable("2022-05-01 00:00:00");
$converter = new WarekiConverter();
$wareki = $converter->convert($datetime);

echo $wareki // 令和元年5月1日

echo $wareki->getGengo() // 令和
echo $wareki->getYear() // 1
echo $wareki->getMonth() // 5
echo $wareki->getDay() // 1