Japanese era Create Date format
Japanese era Settings

This project is not covered by Drupal’s security advisory policy.

Overview

This module provides the Date formater option that enables the year in a date to be displayed as Japanese era name. For example the year 2012 is the 24th year of the Heisei era and this module provides an option that would display it as "平成24".

Features

  • Introduces the "E" option to be used inside the Format string when creating a new Date and Time format (Configuration > Regional and language > Date and time > Formats, or visit /admin/config/regional/date-time/formats)
  • When displaying the date the "E" part outputs the Japanese era name in Japanese alphabet followed by the year number within the era, for example the year 2012 would be displayed as "平成24"
  • Japanese era names are configurable in this module settings (Configuration > Date API >
    Japanese Era, or visit /admin/config/date/japanese_era). Several eras are already set and come with the module but can be changed, and new eras can be added.
  • It only works on Date fields so far, because it depends on Date API, so it's not recommended to use it in the built-in Date types Long, Medium and Short (so you don't get malformatted "Submitted by" text or similar non-field dates). Instead create a new Date type to use with the format that has the "E" option.

Requirements

This module depends on Date API module which is a part of the great Date module.

How to install and configure

Provided you already have the Date API module installed and enabled, install Japanese era module the usual way, unpack it in /sites/all/modules and enable it through the interface (Modules, or visit /admin/modules) or use the drush script to download and enable.

  1. Create a new Date format (Configuration > Regional and language > Date and time > Formats > Add format, or visit /admin/config/regional/date-time/formats/add) with the "E" representing the year. For example enter E年n月j日 as the Format string.
  2. Create a new Date type and set it to use the format you created in step 1. (Configuration > Regional and language > Date and time > Add date type, or visit /admin/config/regional/date-time/types/add.) In our example set the desired Date type name (for example DateOnly) and choose E年n月j日 under Date format.
  3. Go to the Manage display tab of the content type that contains the Date field you want to format, set the Format for that field to "Date and time", and change the option by clicking on the gear icon on the right and set it to use the Date type you created in Step 1, for example DateOnly (E年n月j日)

Done! Your date field year will now be displayed as 平成24. If you use our example the full date will be displayed as 平成24年9月26日 if the date is set to September 26th 2012.

Tutorials

Cookbook: set up Japanese era date on a multilingual site

Credits

This module has been sponsored by Prkos and Nichikare.

Project information

Releases