Đi tới nội dung tài liệu
Underverse UI Logo
ComponentĐa ngôn ngữ

Date Utilities

Date Utilities thuộc nhóm Đa ngôn ngữ. Xem demo trực tiếp, cách tích hợp và các lưu ý triển khai.

Bắt đầu nhanh

Import Date Utilities từ entry công khai. Các ví dụ bên dưới thể hiện những kiểu tương tác và cấu hình được hỗ trợ.

component.tsxtsx
import { DateUtils } from '@underverse-ui/underverse';

Ví dụ tương tác

Dùng thử Date Utilities thật, xem mã ví dụ và tra cứu các prop đã được mô tả.

Đang tải ví dụ tương tác…
Tham chiếu

Tham chiếu API

Tra cứu các thuộc tính, kiểu dữ liệu được chấp nhận, giá trị mặc định và lưu ý về hành vi.

Dữ liệu được sinh từ API TypeScript công khai của thư viện. Kiểu dữ liệu, thuộc tính bắt buộc và giá trị mặc định luôn đồng bộ với mã nguồn.

DateUtils

Namespace
APIKiểuMô tả
formatDate(date: string | Date | null | undefined, locale?: SupportedLocale) => stringFormat date to readable format
formatDateShort(date: string | Date | null | undefined, locale?: SupportedLocale) => stringFormat date to short format
formatTime(date: string | Date | null | undefined, locale?: SupportedLocale) => stringFormat time only
formatDateTime(date: string | Date | null | undefined, locale?: SupportedLocale) => stringFormat date and time
formatTimeAgo(date: string | Date | null | undefined, locale?: SupportedLocale) => stringFormat relative time (time ago)
isToday(date: string | Date | null | undefined) => booleanCheck if date is today
isYesterday(date: string | Date | null | undefined) => booleanCheck if date is yesterday
formatDateForInput(date: string | Date | null | undefined) => stringFormat date for input[type="date"]
formatDateTimeForInput(date: string | Date | null | undefined) => stringFormat date for input[type="datetime-local"]
getDayOfWeek(date: string | Date | null | undefined, locale?: SupportedLocale) => stringGet day of week
formatDateWithDay(date: string | Date | null | undefined, locale?: SupportedLocale) => stringFormat with day of week
formatDateSmart(date: string | Date | null | undefined, locale?: SupportedLocale) => stringSmart date formatting - shows relative time for recent dates, full date for older ones
parseDateString(str: string, locale?: SupportedLocale) => Date | nullParse date string based on locale

Hướng dẫn sử dụng

Cấu hình Date Utilities tại biên ứng dụng. Giữ nguyên placeholder cùng quy tắc ngày, số và số nhiều cho mọi locale được hỗ trợ.

Trợ năng

Khi dùng Date Utilities, hãy giữ trạng thái focus dễ nhận biết, cung cấp tên truy cập khi cần và kiểm tra bàn phím cùng trình đọc màn hình trong ngữ cảnh thực tế.