The Ultimate Khmer Date Utility

The easiest way to handle Khmer & Lunar Dates.

Stop struggling with complex calendar logic. Easily format local times, calculate precise Lunar phases, and predict the exact moment of the Khmer New Year with a single, elegant library.

$npm i @pphatdev/format-datetime
Live Timekm-KH

Loading...

Lunar Date

Loading...

Khmer New Year Calculator

Loading...

Target Year:

Quick Start Guide

1. Basic Formatting

Format any standard JavaScript Date object into localized strings using familiar tokens.

import { FormatDateTime } from '@pphatdev/format-datetime';

const date = new Date();
const formatted = 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';

const date = new Date();
const lunar = 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';

const kny = FormatDateTime.getKhmerNewYear(2024);
console.log(kny);
/* Result: {date: "2024-04-13T15:17:00.000Z", lunarDate: "ថ្ងៃសៅរ៍ ទី៥ ខែចេត្រ ឆ្នាំរោង ឆស័ក ព.ស. ២៥៦៨", angel: "មហោធរៈទេវី"}*/

Interactive Playground

Try:

Standard Tokens

YYYY Year
MMMM Month
DDDD Day
dd Date
hh 12 Hour
HH 24 Hour
mm Minute
ss Second
A AM/PM

Lunar Tokens

BBBB BE Year
JJJJ JS Year
lA Animal
lE Sak
lM Month
ld Day Num
lN Phase
lW Weekday
Live Output
...
Knowledge Base & FAQ

Frequently Asked Questions

Explore key architectural points, Soriyatra astronomical formulas, token mappings, and multi-runtime integration details.

Schema.org Validated
Key Highlight:100% native ECMAScript standard Intl APIs with zero external dependencies, adding only ~4KB (solar) or ~8KB (with lunar) to your bundle.

@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).

TypeScript
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: "២០២៦-០៩-០២ ០១:២៦:៥៩ រសៀល"