Indesign Nepali Post Date

By InDesign Media

0+ active installationsVersion 6.0.0

Show your WordPress dates in Bikram Sambat (BS). Shortcodes, PHP helpers, and a settings page.

Description

This plugin converts Gregorian (AD) dates into Bikram Sambat (BS) so you can display Nepali dates on posts, pages, widgets, or anywhere in your theme.

Handy if you run a Nepali news site, a blog, or any WordPress site that needs BS dates for the publish date, modified date, or just today’s date.

What it does:

  • Converts any AD date to BS, in Nepali or English digits
  • Nepali month names (e.g. असार) and weekday names (e.g. मंगलबार)
  • Custom date format from the settings page
  • Optional post time display after the BS date – 12-hour or 24-hour format, glyphized when Nepali digits are selected
  • Optional CSS wrapper class if you want to style the output
  • Four shortcodes and a few PHP helpers
  • A monthly BS calendar shortcode with clickable day-archive links and a picker for your brand accent color
  • A filter hook if you want to change the output
  • Covers BS 2000 to 2101 (AD 1943 to 2044)
  • No jQuery, no REST calls, no external dependencies

Features

Shortcodes

  • [indnpd_post_date] Prints the current post’s publish date in BS. Takes optional format, lang, and show_time attributes.
  • [indnpd_today_date] Prints today’s BS date. Good for headers, footers, or widgets. Takes optional format, lang, and show_time attributes.
  • [indnpd_number number=”123″] Converts a number to Nepali glyphs (e.g. 123 to १२३). Takes an optional lang attribute.
  • [indnpd_post_calendar] Shows a monthly BS calendar. Days that have at least one published post link to the day archive. Takes optional year, month, and lang attributes. Prev / next arrows navigate between months.

PHP Functions

Primary names (introduced in 3.0.0):

  • indesign_nepali_post_date_get( $datetime ): Convert a date string or timestamp into a formatted BS string.
  • indesign_nepali_post_date_today(): Return today’s date in BS.
  • indesign_nepali_post_date_convert( $number ): Convert a number to Nepali glyphs.
  • indnpd_get_date( $timestamp, $format, $lang ): Same idea, with format and language you can pass in.

Legacy aliases (kept for backward compatibility, still work exactly the same):

  • id_nepali_post_date_get( $datetime )
  • id_nepali_post_date_today()
  • id_nepali_post_date_convert( $number )

Developer API

  • \IndesignMedia\NPD\Manager::convert( $timestamp, $format, $lang ): Static method if you’d rather not use the global function.
  • indesign_nepali_post_date_output filter: Wrap or modify the HTML before it’s returned.

Date Format Tokens

  • d – Day number
  • m – Month number
  • M – Month name (e.g. असार)
  • y – 2-digit year
  • Y – 4-digit year
  • l – Weekday name (e.g. मंगलबार)

Admin Settings Panel

Four tabs: Settings, Shortcodes, Post Calendar, Developer.

  • Localization Style: Pick Traditional Nepali glyphs (०१२) or English digits (012).
  • Date Pattern: Set a custom format string using the tokens above.
  • CSS Wrapper Class: Optionally wrap every date in <span class="your-class"> so you can style it.
  • Post Time: Toggle to show the publish time after the BS date. Choose 12-hour (3:45 PM) or 24-hour (15:45). Digits follow the Localization Style setting. Can be overridden per shortcode with show_time="1" or show_time="0".
  • Real-time Preview: The preview at the top updates as you change the pattern, switch digits, or toggle the time display.
  • Post Calendar tab: Live preview of the calendar plus two controls that persist to the front-end – a toggle for the day-archive post links and an accent color picker for the weekday header, today’s outline, and linked-day styling.
  • Developer tab: Copy-ready snippets for the PHP function, the output filter, and a starter CSS badge style.

Developers

Built and maintained by Indesign Media (https://indesignmedia.net).

Need help, a custom tweak, or integration work? Head to the plugin page or drop us a line.

Installation

  1. Upload the indesign-nepali-post-date folder to /wp-content/plugins/, or install it from the Plugins screen.
  2. Activate it from the Plugins screen.
  3. Open Nepali Post Date in the admin sidebar and set the date format, digit style, and (if you want one) a wrapper class.
  4. Drop any of the shortcodes into a post, page, or widget: [indnpd_post_date], [indnpd_today_date], [indnpd_number number="123"], or [indnpd_post_calendar].

FAQ

Which calendar does it use?

Gregorian (AD) to Bikram Sambat (BS), the official calendar of Nepal. AD 2024 lands around BS 2081.

What date range works?

BS 2000 to BS 2101 (AD 1943-04-14 to AD 2044). Dates outside that range come back unchanged.

How do I show the post date in Nepali from my theme?

Inside The Loop:

<?php echo indesign_nepali_post_date_get( get_the_date('Y-m-d H:i:s') ); ?>

Or if you want to pass your own format and language:

<?php echo indnpd_get_date( get_the_date('Y-m-d H:i:s'), 'd M Y, l', 'nepali' ); ?>

The older id_nepali_post_date_get() name still works if you already have it in your theme.

Can I use English digits?

Yes. Open Nepali Post Date in the admin sidebar and switch Localization Style to Global English (0123). You can also override it per shortcode:

[indnpd_post_date lang="english"]

Or pass "english" as the third argument to indnpd_get_date().

Can I change the date format?

Yes. Set your own Date Pattern in the settings, using these tokens: d (day), m (month number), M (month name), y (2-digit year), Y (4-digit year), l (weekday). For example, d M Y, l gives you २५ असार २०८१, मंगलबार.

You can also pass a format directly in the shortcode: [indnpd_post_date format="d M Y"]

How do I modify the output from PHP?

Use the indesign_nepali_post_date_output filter. You get the HTML string, the BS date array, and the Unix timestamp.

add_filter( 'indesign_nepali_post_date_output', function( $html, $bs, $unix ) {
    return '<span class="nepali-badge">' . $html . '</span>';
}, 10, 3 );

How do I add the Nepali calendar to a page?

Drop [indnpd_post_calendar] into any post, page, or widget. It shows the current BS month by default. Use the prev / next arrows in the header to browse.

To pin it to a specific month:

[indnpd_post_calendar year="2083" month="4" lang="english"]

What do the clickable days on the calendar do?

Each past-or-current day cell links to the WordPress day archive for that Gregorian date (the same URL WordPress generates for /YYYY/MM/DD/). Clicking a day takes visitors to the list of posts published on that day. Future dates are never linked.

Can I turn off the day-archive links?

Yes. Open Nepali Post Date in the admin sidebar, go to the Post Calendar tab, and switch off the Post Links toggle on the calendar preview. Save Changes. The front-end calendar will then render as a plain, non-clickable calendar.

Can I change the calendar’s accent color to match my brand?

Yes. On the same Post Calendar tab, use the color picker on the calendar preview. The color drives the weekday header row, today’s outline, and the linked-day text color. Save Changes and the front-end will pick it up.

Does the calendar highlight today’s date?

Yes. Today (in Nepal time) is outlined with your chosen accent color, regardless of your WordPress site’s timezone. The BS day always rolls at Nepal midnight.

Can I use the calendar in a widget or template file?

Yes. Widgets that accept shortcodes render [indnpd_post_calendar] directly. In a template file:

<?php echo do_shortcode('[indnpd_post_calendar]'); ?>

Will the calendar work with any theme’s day archive?

Yes. It uses WordPress core’s get_day_link(), which produces the standard /YYYY/MM/DD/ URL. Any theme that renders the day archive template (date.php, archive.php, or index.php) will handle those links correctly.

Screenshots

Changelog

6.0.0

  • New: Post time display. A new Post Time toggle in the Settings tab appends the publish time after the BS date. Choose 12-hour (3:45 PM) or 24-hour (15:45) format. When Nepali digits are selected the time digits are glyphized too (e.g. ३:४५ PM).
  • New: show_time shortcode attribute on [indnpd_post_date] and [indnpd_today_date]. Use show_time="1" to force time on or show_time="0" to force it off for that instance, regardless of the global setting.
  • New: processTimestamp() accepts an optional $show_time parameter for direct PHP callers.
  • Updated: Live preview in the admin settings header now reflects time changes in real time as you toggle the setting, switch the format, or change the digit style.

4.5.0

  • Fixed: Corrected month-day data for multiple BS years in the CalendarProvider table. Incorrect values were causing wrong date conversions for the affected years.

4.0.0

  • Fixed: [indnpd_post_date] and indesign_nepali_post_date_get() used a WordPress local-time string for the BS conversion. On sites where the WordPress timezone differs from Asia/Kathmandu, posts published in the evening could display the wrong BS date. Both now use the post’s UTC Unix timestamp and convert directly to NPT, matching how [indnpd_today_date] has always worked.
  • Fixed: indnpd_get_date() was defined inside the IndesignMedia\NPD namespace, making it unreachable from theme templates. A global wrapper is now registered in the main plugin file.
  • Fixed: INDNPD_VERSION constant was not updated in 3.5.0 and still read 3.0.0.
  • Fixed: BS 2082 Baisakh was set to 30 days, should be 31. This caused a one-day forward drift for all dates from Jestha 2082 onwards.

3.0.0

  • New: [indnpd_post_calendar] shortcode. Renders a monthly BS calendar. Days link to the WordPress day archive for that Gregorian date. Prev / next arrows navigate between BS months. Takes optional year, month, and lang attributes. Future dates are never linked.
  • New: Post Calendar admin tab with a live preview, a Post Links toggle to enable or disable the day-archive links site-wide, and an accent color picker for the weekday header, today’s outline, and linked-day styling.
  • New primary function names: indesign_nepali_post_date_get(), indesign_nepali_post_date_today(), indesign_nepali_post_date_convert(). The old id_nepali_post_date_* names are kept as backward-compatible aliases so nothing you already wrote stops working.
  • Fixed a one-day drift in the BS calendar table. BS 2069 Chaitra was set to 31 days, should be 30. BS 2070 Jestha was set to 31, should be 32. Vaisakh 1 boundaries now match the Government of Nepal patro across BS 2000 to 2101 (checked against 9 anchor dates).
  • BS conversion now always uses Asia/Kathmandu (UTC+05:45) for the day boundary, no matter what timezone your WordPress site is set to. The BS date rolls over at Nepal midnight, not your server’s midnight.
  • Redesigned the settings page. Two columns, pill tabs across the top (Settings, Shortcodes, Post Calendar, Developer), white header card, red gradient for the active tab and Save button. Promo banners moved to the right sidebar.
  • The preview at the top of the settings page updates as you type in the Date Pattern or switch digit style. No page reload, no AJAX.

2.0.0

  • Fixed: Date display off by one day for posts published in the evening Nepal time. Root cause was a double timezone conversion: strtotime() interpreted the local-timezone datetime string as UTC, then wp_date() added the Nepal offset again, pushing evening dates to the next day. Now uses date_create($raw, wp_timezone()) to parse datetime strings correctly in the WordPress timezone with no offset drift.

1.0.0

  • First release.
  • BS date conversion via shortcodes and PHP helpers.
  • Covers BS 2000 to 2101 (AD 1943 to 2044).
  • PHP 8.2 enum-based month and weekday localization.
  • Format tokens: d, m, M, y, Y, l.
  • Nepali glyphs or English digits.
  • Optional CSS wrapper class.
  • Live preview on the settings page.
  • indesign_nepali_post_date_output filter.
  • indnpd_get_date() helper and Manager::convert() static method.