npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@inverz/thai-date

v1.0.1

Published

Thai date helpers: format with Thai month/day names and Buddhist-era years, parse Thai dates, relative time and age — no dependencies

Readme

@inverz/thai-date

npm size license

ฟังก์ชันจัดการวันที่ภาษาไทย: จัดรูปแบบด้วยชื่อเดือน/วันภาษาไทยและปี พ.ศ., อ่านวันที่ไทยกลับเป็น Date, แสดงเวลาที่ผ่านมา ("5 นาทีที่แล้ว") และคำนวณอายุ ไม่มี dependency ไม่ผูกกับ React ใช้ได้ทั้งเบราว์เซอร์และ Node.js

ดูตัวอย่าง (Demo)

Thai date helpers with Buddhist-era years: format, parse, relative time and age. Zero dependencies, ~2 KB gzip, works in the browser and on the server.

ติดตั้ง

npm i @inverz/thai-date

จัดรูปแบบ

import { formatThaiDate, formatThaiTime } from "@inverz/thai-date";

formatThaiDate(date);              // "27 ก.ย. 2569"
formatThaiDate(date, "short");     // "27 ก.ย. 69"
formatThaiDate(date, "long");      // "27 กันยายน 2569"
formatThaiDate(date, "full");      // "วันอาทิตย์ที่ 27 กันยายน พ.ศ. 2569"
formatThaiDate(date, "numeric");   // "27/09/2569"
formatThaiDate(date, "datetime");  // "27 ก.ย. 2569 14:30 น."
formatThaiTime(date);              // "14:30 น."

date เป็น Date, สตริง ISO หรือ timestamp ก็ได้ ถ้าวันที่ไม่ถูกต้องหรือว่างจะได้ ""

กำหนดรูปแบบเอง

formatThaiDate(date, "วันEEEEที่ d MMMM BBBB เวลา HH:mm น.");
// "วันอาทิตย์ที่ 27 กันยายน 2569 เวลา 14:30 น."

| Token | ได้ | |---|---| | d dd | 7, 07 | | M MM | 9, 09 | | MMM MMMM | ก.ย., กันยายน | | BB BBBB | 69, 2569 (พ.ศ.) | | yy yyyy | 26, 2026 (ค.ศ.) | | EEE EEEE | อา., อาทิตย์ | | H HH mm ss | ชั่วโมง นาที วินาที | | 'ข้อความ' | พิมพ์ตามนั้น (ใช้กับตัวอักษรอังกฤษที่ไม่ใช่ token) |

อ่านวันที่ไทย

import { parseThaiDate } from "@inverz/thai-date";

parseThaiDate("27/09/2569");                          // Date 2026-09-27
parseThaiDate("27 ก.ย. 69");                          // Date 2026-09-27
parseThaiDate("วันอาทิตย์ที่ 27 กันยายน พ.ศ. 2569");  // Date 2026-09-27
parseThaiDate("27 ก.ย. 2569 14:30 น.");               // Date 2026-09-27 14:30
parseThaiDate("2026-09-27");                          // Date 2026-09-27 (ปีขึ้นก่อนแบบ ISO)
parseThaiDate("31/02/2569");                          // null
  • ปีที่มากกว่า 2400 ถือเป็น พ.ศ. น้อยกว่านั้นเป็น ค.ศ. ปี 2 หลักถือเป็น พ.ศ. 25xx
  • ใช้ / - หรือ . คั่นได้ ชื่อเดือนแบบเต็ม แบบย่อ มีหรือไม่มีจุดก็ได้
  • วันที่ที่ไม่มีจริง (31/02, 29/02 ในปีที่ไม่ใช่ปีอธิกสุรทิน) ได้ null

เวลาที่ผ่านมา

import { timeAgo } from "@inverz/thai-date";

timeAgo(date);          // "เมื่อสักครู่", "5 นาทีที่แล้ว", "3 ชั่วโมงที่แล้ว", "เมื่อวาน",
                        // "4 วันที่แล้ว", "2 สัปดาห์ที่แล้ว", "3 เดือนที่แล้ว", "1 ปีที่แล้ว"
timeAgo(future);        // "อีก 10 นาที", "พรุ่งนี้", "อีก 3 วัน"
timeAgo(date, now);     // เทียบกับเวลาที่กำหนดเอง (เช่น เวลาจาก server)

อายุ

import { getAge, formatAge } from "@inverz/thai-date";

getAge(birthDate);      // { years: 31, months: 6, days: 12 }
formatAge(birthDate);   // "31 ปี 6 เดือน 12 วัน"

ปี ค.ศ. ↔ พ.ศ.

import { toBuddhistYear, fromBuddhistYear } from "@inverz/thai-date";

toBuddhistYear(2026);        // 2569
toBuddhistYear(new Date());  // 2569
fromBuddhistYear(2569);      // 2026

ชื่อเดือนและวันใช้ได้โดยตรงด้วย: THAI_MONTHS, THAI_MONTHS_SHORT, THAI_DAYS, THAI_DAYS_SHORT

ใช้คู่กับแพ็กเกจอื่นของ Inverz

License

MIT © 2026 Inverz Solutions Co.,Ltd.