Question
Unresolved Behavior: Sorting Localized Dates in DataTables
Zo Nea
0 reputation · 03 Aug 2020, 20:17 UTC
60.3K views0
Goal
Display dates in the user’s local timezone while preserving correct chronological order in a DataTable.
Constraints
- Server returns UTC timestamps in ISO 8601.
- Client-side rendering uses the DataTables
rendercallback. - External libraries such as Moment.js are deprecated; Intl.DateTimeFormat or Luxon are preferred.
Unresolved Behavior
When the column renders a localized date string without an explicit sort key, DataTables falls back to alphabetical sorting, which misorders dates that share the same locale format.
Questions
- Which approach should I adopt to supply a stable sort key alongside a localized string when using the
renderfunction? - Can the
data-orderattribute be generated dynamically from the rendered value to ensure correct sorting? - Does the built‑in
datetimerendering plugin support timezone conversion without Moment.js, and if so, how?