The easiest way to handle
Khmer & Lunar Calendars.
Check what day is today in Cambodia, explore traditional Khmer lunar dates (ប្រតិទិនចន្ទគតិ), convert Buddhist Era years, and format dates with zero dependencies in TypeScript and modern JavaScript.
npm i @pphatdev/format-datetimeLoading...
Loading...
Loading...
Quick Start Guide
1. Basic Formatting
Format any standard JavaScript Date object into localized strings using familiar tokens.
import{ FormatDateTime }from'@pphatdev/format-datetime';constdate =newDate();constformatted =FormatDateTime.format(date,'DD MMMM YYYY','km');// Result: "០១ មករា ២០២៤"
2. Lunar Date Conversion
Instantly convert Gregorian dates into the traditional Khmer Lunar calendar system.
import{ FormatDateTime }from'@pphatdev/format-datetime';constdate =newDate();constlunar =FormatDateTime.getLunarDate(date);// Result: "ថ្ងៃចន្ទ ទី១ ខែមករា ឆ្នាំរោង ឆស័ក ព.ស. ២៥៦៨"
3. Khmer New Year Calculation
Calculate the exact time and date of the Khmer New Year (Moha Sangkran) for any given year.
import{ FormatDateTime }from'@pphatdev/format-datetime';constkny =FormatDateTime.getKhmerNewYear(2024);console.log(kny);/* Result: {date: "2024-04-13T15:17:00.000Z", lunarDate: "ថ្ងៃសៅរ៍ ទី៥ ខែចេត្រ ឆ្នាំរោង ឆស័ក ព.ស. ២៥៦៨", angel: "មហោធរៈទេវី"}*/
Interactive Playground
Standard Tokens
Lunar Tokens
Frequently Asked Questions
Explore key architectural points, Soriyatra astronomical formulas, token mappings, and multi-runtime integration details.
@pphatdev/format-datetime is a zero-dependency, high-performance TypeScript library designed for formatting dates and times into localized strings. It features first-class Khmer (km-KH) localization with native Khmer numerals (០-៩), traditional time-of-day phrases, and full astronomical Khmer lunar calendar arithmetic (Buddhist Era, Jolak Sakaraj, 12-animal cycle, 10-era Sak, and waxing/waning moon phases).
import { FormatDateTime } from '@pphatdev/format-datetime'; const dt = new FormatDateTime(new Date(), 'YYYY-MM-DD hh:mm:ss A', 'km-KH');console.log(dt.formatDate()); // Output: "២០២៦-០៩-០២ ០១:២៦:៥៩ រសៀល"