A WordPress plugin that displays dates and times in various calendar systems using the ECMAScript Internationalization API (Intl) while maintaining SEO friendliness.
- Support for multiple calendar systems (Gregorian, Buddhist, Chinese, Hebrew, Islamic, etc.)
- Configurable date and time formatting styles
- Automatic localization based on language settings
- Full support for WordPress block editor (Gutenberg)
- SEO-friendly implementation (original datetime values are preserved in the HTML)
- Lightweight with no jQuery dependency
- Optimized with minified JavaScript for production
Once activated, the plugin will automatically format all dates and times on your site according to your selected calendar system and locale.
- Go to 'Settings' > 'Intl DateTime Calendar' in the WordPress admin
- Select your preferred calendar system (Gregorian, Buddhist, Chinese, etc.)
- Choose your locale (e.g., 'en', 'th-TH', 'ja-JP')
- Set date and time style preferences (Full, Long, Medium, Short)
- Save changes
The plugin supports the following calendar systems:
buddhist: Buddhist Calendarchinese: Chinese Calendarcoptic: Coptic Calendardangi: Dangi (Korean) Calendarethioaa: Ethiopic (Amete Alem) Calendarethiopic: Ethiopic Calendargregory: Gregorian (Western) Calendarhebrew: Hebrew Calendarindian: Indian Calendarislamic: Islamic Calendarislamic-civil: Islamic (Civil) Calendarislamic-rgsa: Islamic (Saudi Arabia) Calendarislamic-tbla: Islamic (Tabular) Calendarislamic-umalqura: Islamic (Umm al-Qura) Calendariso8601: ISO 8601 Calendarjapanese: Japanese Calendarpersian: Persian Calendarroc: Republic of China Calendar
Each style provides a different level of formatting detail:
full: e.g., "Wednesday, December 31, 2023"long: e.g., "December 31, 2023"medium: e.g., "Dec 31, 2023"short: e.g., "12/31/23"
If you need to format a specific date manually in your theme or plugin, you can use this format:
<?php
$timestamp = strtotime('2023-12-31 23:59:59') * 1000; // Convert to milliseconds for JS
?>
<span class="intl-datetime intl-datetime-auto"
data-intl-datetime="<?php echo esc_attr($timestamp); ?>"
data-calendar="buddhist"
data-locale="th-TH"
data-date-style="full"
data-time-style="long">
December 31, 2023
</span>You can also format dates programmatically using the provided JavaScript API:
// Example: Format the current date
const timestamp = Date.now();
const options = {
calendar: 'buddhist',
locale: 'th-TH',
dateStyle: 'full',
timeStyle: 'long'
};
const formatter = new Intl.DateTimeFormat(options.locale, {
calendar: options.calendar,
dateStyle: options.dateStyle,
timeStyle: options.timeStyle
});
const formattedDate = formatter.format(new Date(timestamp));
console.log(formattedDate);This plugin utilizes the Intl API, which is supported in all modern browsers:
- Chrome 76+
- Firefox 72+
- Safari 14+
- Edge 79+
For older browsers, the plugin will fall back to the browser's default date formatting.
The plugin automatically checks for updates from the GitHub repository. When a new version is released, you'll receive an update notification in your WordPress admin dashboard.
Contributions are welcome! Please feel free to submit a Pull Request.
This plugin is licensed under the GPL v2 or later.