field-datetime
Ngày và giờ Bốn trường mà datetime.js tăng cường, mỗi trường vẫn giữ ô nhập gốc bên dưới, để người đọc không có script nhận được điều khiển thuần chứ không phải một thứ hỏng.
Ngày và giờ trong một ô nhập, một giá trị.
Mỗi ví dụ đều hoạt động thật, nhưng các liên kết trong đó không dẫn đến đâu. HTML hiển thị mã đánh dấu để sao chép.
Ô nhập nâng cao: gõ "ngày mai" hoặc "sau 3 tuần"
Những từ nó phân tích nằm trên data-rst-date-words, ở đây bằng ngôn ngữ của trang. i18n/<lang>.json có chúng bằng mười hai ngôn ngữ, nên ô nhập có thể phân tích bất kỳ ngôn ngữ nào mà trang đang dùng.
Đặt đoạn này bên trong <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="field-datetime_live" >Ngày xuất bản</label >
<input rst-input id ="field-datetime_live" name ="field-datetime_live" type ="datetime-local" value ="2026-09-04T19:30" aria-describedby ="field-datetime_live-hint" data-rst-date data-rst-date-words ="{"ago":"trước","am":"sáng|am","at":"lúc|vào","day":"ngày","hour":"giờ|tiếng|h","in":"nữa|sau","last":"trước|qua|rồi","midnight":"nửa đêm","minute":"phút|p","month":"tháng","next":"tới|tiếp|sau","noon":"giữa trưa|trưa","pm":"chiều|tối|pm","today":"hôm nay|nay","tomorrow":"ngày mai|mai","week":"tuần","yesterday":"hôm qua"}" data-rst-date-set ="Đặt" data-rst-date-hint ="Thử: {example}" data-rst-date-pick ="Mở lịch" data-rst-date-calendar ="Lịch" data-rst-date-prev-month ="Tháng trước" data-rst-date-next-month ="Tháng sau" data-rst-date-results ="{n} gợi ý" data-rst-date-result-one ="1 gợi ý" data-rst-date-quick-today ="Hôm nay" data-rst-date-quick-tomorrow ="Ngày mai" data-rst-date-quick-next-week ="Một tuần nữa" data-rst-date-quick-plus-1h ="Một giờ sau" data-rst-date-quick-plus-2h ="Hai giờ sau" data-rst-date-quick-end-of-day ="Cuối ngày hôm đó" data-rst-date-quick-next-day ="Cùng giờ ngày hôm sau" >
<small rst-field-hint id ="field-datetime_live-hint" >Thời điểm bắt đầu hiển thị.</small >
</div >
Bắt buộc, kèm lỗi
Đặt đoạn này bên trong <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="field-datetime_error" >Ngày xuất bản <span rst-field-required aria-hidden ="true" >*</span ></label >
<input rst-input id ="field-datetime_error" name ="field-datetime_error" type ="datetime-local" required aria-invalid ="true" aria-describedby ="field-datetime_error-error" data-rst-date data-rst-date-words ="{"ago":"trước","am":"sáng|am","at":"lúc|vào","day":"ngày","hour":"giờ|tiếng|h","in":"nữa|sau","last":"trước|qua|rồi","midnight":"nửa đêm","minute":"phút|p","month":"tháng","next":"tới|tiếp|sau","noon":"giữa trưa|trưa","pm":"chiều|tối|pm","today":"hôm nay|nay","tomorrow":"ngày mai|mai","week":"tuần","yesterday":"hôm qua"}" data-rst-date-set ="Đặt" data-rst-date-hint ="Thử: {example}" data-rst-date-pick ="Mở lịch" data-rst-date-calendar ="Lịch" data-rst-date-prev-month ="Tháng trước" data-rst-date-next-month ="Tháng sau" data-rst-date-results ="{n} gợi ý" data-rst-date-result-one ="1 gợi ý" data-rst-date-quick-today ="Hôm nay" data-rst-date-quick-tomorrow ="Ngày mai" data-rst-date-quick-next-week ="Một tuần nữa" data-rst-date-quick-plus-1h ="Một giờ sau" data-rst-date-quick-plus-2h ="Hai giờ sau" data-rst-date-quick-end-of-day ="Cuối ngày hôm đó" data-rst-date-quick-next-day ="Cùng giờ ngày hôm sau" >
<small rst-field-error id ="field-datetime_error-error" >Chọn một ngày sau hôm nay.</small >
</div >
Có giới hạn
Đặt đoạn này bên trong <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="field-datetime_bounded" >Trong năm nay</label >
<input rst-input id ="field-datetime_bounded" name ="field-datetime_bounded" type ="datetime-local" value ="2026-09-04T19:30" min ="2026-01-01T00:00" max ="2026-12-31T23:59" data-rst-date data-rst-date-words ="{"ago":"trước","am":"sáng|am","at":"lúc|vào","day":"ngày","hour":"giờ|tiếng|h","in":"nữa|sau","last":"trước|qua|rồi","midnight":"nửa đêm","minute":"phút|p","month":"tháng","next":"tới|tiếp|sau","noon":"giữa trưa|trưa","pm":"chiều|tối|pm","today":"hôm nay|nay","tomorrow":"ngày mai|mai","week":"tuần","yesterday":"hôm qua"}" data-rst-date-set ="Đặt" data-rst-date-hint ="Thử: {example}" data-rst-date-pick ="Mở lịch" data-rst-date-calendar ="Lịch" data-rst-date-prev-month ="Tháng trước" data-rst-date-next-month ="Tháng sau" data-rst-date-results ="{n} gợi ý" data-rst-date-result-one ="1 gợi ý" data-rst-date-quick-today ="Hôm nay" data-rst-date-quick-tomorrow ="Ngày mai" data-rst-date-quick-next-week ="Một tuần nữa" data-rst-date-quick-plus-1h ="Một giờ sau" data-rst-date-quick-plus-2h ="Hai giờ sau" data-rst-date-quick-end-of-day ="Cuối ngày hôm đó" data-rst-date-quick-next-day ="Cùng giờ ngày hôm sau" >
</div >
Plain: ô nhập gốc để trơn
Không có thuộc tính tăng cường nào cả, nên datetime.js chẳng tìm thấy gì. Bộ chọn gốc vẫn mở được.
Đặt đoạn này bên trong <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="field-datetime_plain" >Ngày xuất bản</label >
<input rst-input id ="field-datetime_plain" name ="field-datetime_plain" type ="datetime-local" value ="2026-09-04T19:30" >
</div >