伝えたいこと 備忘録 時事ネタ

プロモーションを含みます

2025年10月10日は昭和100年10月10日。平成換算と令和換算

目次に行く・戻る

メルカリ招待コード:

所要時間目安: 6

This session is using  IPv4  is established in

今日は2025年11月3日です。

巷で、2025年10月10日は昭和で表すと昭和100年10月10日だということのようです。そこで、今後も日本の元号(昭和・平成・令和)にて自動的に換算表示するようにしてみました。まずは、昭和の元号は始まったのは1926年12月25日です。そして、平成の元号がは始まったのは1989年1月8日です。そして、現在の令和の元号が始まったのは2019年5月1日からです。それぞれ昭和と平成はそのまま昭和元号が続いたとしての年号と平成が続いたとしての年号。そして、現在の令和の元号の元号表記を以下に記載しておいてみたいなと思いました。

この記事を読む方へのオススメ

昭和元号が続いたとしての昭和何年何月か?

昭和100年11月3日

次に、平成の元号は2019年4月いっぱいで翌日の2019年5月1日からは令和の元号になりましたが、平成だった場合の平成換算表示は以下になります。

平成37年11月3日

最後に、現在の日本の元号は「令和」なので、令和表記の日付は以下になります。

令和7年11月3日

どうでしょうか?
少し、感慨深さや情緒性?があるのではないでしょうか?

  • 昭和生の方、
  • 平成生まれの方、
  • 令和生の方、

それぞれにわかりやすいように3つの元号ごとに表記してみました。

ちなみに、今日は以下の表記になります。

令和7年11月3日

以下のゲームサイト?にても話題になっているようです。

Yahooニュースなどでも話題になっていますね。

上記の昭和100年10月10日と平成37年10月10日と令和7年10月10日は、以下のコードにて自動的に表示するようにしています。

/**
 * 日本の元号換算ショートコード
 * 自動判定:[jp_era_year] / [jp_era_full]
 * 固定換算:[showa_year] / [showa_full] / [heisei_year] / [heisei_full] / [reiwa_year] / [reiwa_full]
 */
function shortcode_jp_era($atts, $content = null, $tag = '') {
    $today = new DateTime();

// 各元号の開始日(昭和のみ実際の元号開始日は1926年12月25日ですが、10月10日を昭和100年と表示されるように日付部分のみ変更) $showa_start = new DateTime('1926-10-09'); $heisei_start = new DateTime('1989-01-08'); $reiwa_start = new DateTime('2019-05-01');

// デフォルト(自動判定) $era = ''; $era_year = 0;

// 強制元号表示(ショートコード名で分岐) switch ($tag) { case 'showa_year': case 'showa_full': $interval = $showa_start->diff($today); $era = '昭和'; $era_year = $interval->y + 1; break;

case 'heisei_year': case 'heisei_full': $interval = $heisei_start->diff($today); $era = '平成'; $era_year = $interval->y + 1; break;

case 'reiwa_year': case 'reiwa_full': $interval = $reiwa_start->diff($today); $era = '令和'; $era_year = $interval->y + 1; break;

default: // 自動判定(現在日付から) if ($today >= $reiwa_start) { $interval = $reiwa_start->diff($today); $era = '令和'; } elseif ($today >= $heisei_start) { $interval = $heisei_start->diff($today); $era = '平成'; } else { $interval = $showa_start->diff($today); $era = '昭和'; } $era_year = $interval->y + 1; }

// 月日を取得 $month = $today->format('n'); $day = $today->format('j');

// 出力 if (strpos($tag, '_full') !== false) { return $era . $era_year . '年' . $month . '月' . $day . '日'; } else { return $era . $era_year . '年'; } }

// 自動判定ショートコード add_shortcode('jp_era_year', 'shortcode_jp_era'); add_shortcode('jp_era_full', 'shortcode_jp_era');

// 固定元号ショートコード add_shortcode('showa_year', 'shortcode_jp_era'); add_shortcode('showa_full', 'shortcode_jp_era'); add_shortcode('heisei_year', 'shortcode_jp_era'); add_shortcode('heisei_full', 'shortcode_jp_era'); add_shortcode('reiwa_year', 'shortcode_jp_era'); add_shortcode('reiwa_full', 'shortcode_jp_era');

なので、あなたがこのサイトに訪れていただいた日付が表示されるようになっています。

例えば以下のように本日の日付が表示されます。

昭和100年11月3日
平成37年11月3日
令和7年11月3日

上記のように、それぞれ

  • 「昭和」
  • 「平成」
  • 「令和」

を真ん中(中央)に表示するようにするには、以下コードのように直接スタイル調整して表示します。

/**
 * 日本の元号換算ショートコード(昭和・平成・令和対応・中央寄せ表示)
 * 自動判定:[jp_era_year] / [jp_era_full]
 * 固定換算:[showa_year] / [showa_full] / [heisei_year] / [heisei_full] / [reiwa_year] / [reiwa_full]
 */
function shortcode_jp_era($atts, $content = null, $tag = '') {
    $today = new DateTime();

// 各元号の開始日(昭和のみ実際の元号開始日は1926年12月25日ですが、10月10日を昭和100年と表示されるように日付部分のみ変更) $showa_start = new DateTime('1926-10-09'); $heisei_start = new DateTime('1989-01-08'); $reiwa_start = new DateTime('2019-05-01');

// デフォルト $era = ''; $era_year = 0;

// 誤差のない年数計算 $calc_era_year = function($start, $today) { $sy = (int)$start->format('Y'); $sm = (int)$start->format('n'); $sd = (int)$start->format('j'); $ty = (int)$today->format('Y'); $tm = (int)$today->format('n'); $td = (int)$today->format('j');

$year_diff = $ty - $sy; return ($tm > $sm || ($tm === $sm && $td >= $sd)) ? $year_diff + 1 : $year_diff; };

// ショートコードごとに分岐 switch ($tag) { case 'showa_year': case 'showa_full': $era = '昭和'; $era_year = $calc_era_year($showa_start, $today); break;

case 'heisei_year': case 'heisei_full': $era = '平成'; $era_year = $calc_era_year($heisei_start, $today); break;

case 'reiwa_year': case 'reiwa_full': $era = '令和'; $era_year = $calc_era_year($reiwa_start, $today); break;

default: if ($today >= $reiwa_start) { $era = '令和'; $era_year = $calc_era_year($reiwa_start, $today); } elseif ($today >= $heisei_start) { $era = '平成'; $era_year = $calc_era_year($heisei_start, $today); } else { $era = '昭和'; $era_year = $calc_era_year($showa_start, $today); } }

// 月日 $month = $today->format('n'); $day = $today->format('j');

// 出力内容 $text = (strpos($tag, '_full') !== false) ? $era . $era_year . '年' . $month . '月' . $day . '日' : $era . $era_year . '年';

// スタイル付きで中央寄せ・フォントサイズ20pxに return '<div style="text-align:center; font-size:20px; line-height:1.8;">' . esc_html($text) . '</div>'; } // ショートコード登録 add_shortcode('jp_era_year', 'shortcode_jp_era'); add_shortcode('jp_era_full', 'shortcode_jp_era'); add_shortcode('showa_year', 'shortcode_jp_era'); add_shortcode('showa_full', 'shortcode_jp_era'); add_shortcode('heisei_year', 'shortcode_jp_era'); add_shortcode('heisei_full', 'shortcode_jp_era'); add_shortcode('reiwa_year', 'shortcode_jp_era'); add_shortcode('reiwa_full', 'shortcode_jp_era');

初めのコードと下のコードでは少し異なりますが、基本的な動作は同じになります。ご参考まで。

あなたにおすすめ


Multiplex 広告

入学入社まであと…入学入社祝いはどんなPresent(プレゼント)でどのように過ごされますか?

ホワイトデープレゼントは以下などの豊富なキャンペーン商品から選ぶと良いと思います。

ブログサービスが始まってから:


カウントダウンタイマー

おすすめの記事一部広告

Total115


アドセンス336pxPC閲覧記事下表示1つ目コード

目次に戻る

よろしかったらシェアよろしくお願いします。

-伝えたいこと, 備忘録, 時事ネタ

目次に戻る

目次に戻る


コメントを表示(0)

コメントを書く

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

新着コメント