Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
Get relative date in auto format using Luxon

Trying a simple code here using Intl library internally on top of Luxon here to get relative dates. If my current date is in 2 hours ago, in 2 hours, etc, I want it to display today. Else, I want it to display 1 day ago or in 1 day.

I have numeric set to auto but it doesn't seem to get picked up.

const {DateTime} = require('luxon');

console.log(DateTime.fromMillis(Date.now() - 10090909).toRelative({
    numeric: 'auto',
})); 

// Date.now - 10090909 is 2 hours ago,
// but output here comes out to be 0 days ago
// expected is today

Sources I m referring:

  1. Intl Relative Date API
  2. Luxon Relative Date
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!