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

@libs-ui/pipes-format-date

v0.2.356-1

Published

> Bộ đôi pipe hỗ trợ định dạng thời gian và khởi tạo đối tượng Dayjs cho Angular 18+.

Downloads

1,527

Readme

@libs-ui/pipes-format-date

Bộ đôi pipe hỗ trợ định dạng thời gian và khởi tạo đối tượng Dayjs cho Angular 18+.

Giới thiệu

@libs-ui/pipes-format-date cung cấp hai pipe standalone:

  • LibsUiPipesFormatDatePipe: Định dạng thời gian từ nhiều kiểu đầu vào (Date, ISO string, timestamp) thành chuỗi hiển thị.
  • LibsUiPipesGetDayjsPipe: Khởi tạo và trả về đối tượng Dayjs từ cấu hình cho trước.

Cả hai đều được thiết kế tối ưu, hỗ trợ đa ngôn ngữ và tree-shaking.

Tính năng

  • Linh hoạt: Chấp nhận đầu vào là string, number, Date hoặc Dayjs object.
  • Định dạng tùy biến: Hỗ trợ mọi định dạng mà Dayjs cho phép.
  • Đa ngôn ngữ: Dễ dàng thay đổi locale (vi, en, ...).
  • Hiệu năng: Pure pipe, chỉ thực thi lại khi input tham chiếu thay đổi.
  • Standalone: Dễ dàng import vào bất kỳ component nào.
  • Dayjs Integration: Tích hợp sâu với thư viện xử lý thời gian mạnh mẽ.

Khi nào sử dụng

  • Khi cần hiển thị ngày tháng năm trong template HTML theo định dạng chuẩn (ví dụ: DD/MM/YYYY).
  • Khi cần track sự thay đổi thời gian trong template mà không muốn viết quá nhiều logic trong component class.
  • Khi cần lấy đối tượng Dayjs từ một config JSON trong template để thực hiện các phép tính ngày tháng nhanh.

Cài đặt

# npm
npm install @libs-ui/pipes-format-date

# yarn
yarn add @libs-ui/pipes-format-date

Import

import { LibsUiPipesFormatDatePipe, LibsUiPipesGetDayjsPipe } from '@libs-ui/pipes-format-date';

@Component({
  standalone: true,
  imports: [LibsUiPipesFormatDatePipe, LibsUiPipesGetDayjsPipe],
  // ...
})
export class YourComponent {}

Ví dụ

Định dạng ngày tháng cơ bản

<!-- Mặc định: YYYY/MM/DD HH:mm -->
<span>{{ timestamp | LibsUiPipesFormatDatePipe }}</span>

<!-- Custom format -->
<span>{{ dateString | LibsUiPipesFormatDatePipe:'DD/MM/YYYY' }}</span>

Định dạng với ngôn ngữ cụ thể

<span>{{ now | LibsUiPipesFormatDatePipe:'dddd, DD MMMM YYYY':'vi' }}</span>

Lấy đối tượng Dayjs

@let dayjsObj = (config | LibsUiPipesGetDayjsPipe); @if (dayjsObj) {
<span>Year: {{ dayjsObj.year() }}</span>
}

API

LibsUiPipesFormatDatePipe

Parameters

| Property | Type | Default | Description | | -------------- | ------------------------------------------------------ | -------------------- | ---------------------------------------------------------------------- | | time | string \| number \| dayjs.Dayjs \| null \| undefined | undefined | Giá trị thời gian cần định dạng | | formatOutput | string | 'YYYY/MM/DD HH:mm' | Định dạng đầu ra mong muốn | | lang | string | undefined | Ngôn ngữ hiển thị (vi, en, ...) | | formatInput | string | undefined | Định dạng của chuỗi đầu vào (trường hợp dayjs không tự nhận diện được) |

LibsUiPipesGetDayjsPipe

Parameters

| Property | Type | Default | Description | | -------- | ------------------------------------------------------ | ----------- | ------------------------------- | | config | { date?: any, utc?: boolean, formatOfDate?: string } | undefined | Cấu hình để tạo đối tượng Dayjs |

Công nghệ

| Technology | Version | Purpose | | -------------- | ---------- | -------------- | | Angular | 18+ | Framework | | Day.js | 1.11.5 | Date logic | | @libs-ui/utils | 0.2.355-15 | Core utilities |

Demo

Chạy demo page để xem trực quan các ví dụ:

npm run demo

Unit Tests

npx nx test pipes-format-date
npx nx test pipes-format-date --coverage

License

MIT