Data MasteryWednesday, January 28, 2026

Dates & Time

Handling time in JavaScript.

Advertisement

Support JS Mastery Path by checking out our sponsors.

The native Date object is clumsy. For complex apps, professionals use libraries like date-fns or Luxon.

Native Formatting

const now = new Date();

// The "Internationalization" API is the modern native way
const readable = new Intl.DateTimeFormat('en-US', {
  dateStyle: 'full',
  timeStyle: 'short'
}).format(now);

console.log(readable); 
// "Tuesday, January 6, 2026 at 2:30 PM"

Pro Tip

Always store dates in your database as UTC ISO Strings (2024-01-01T12:00:00Z). Convert them to the user's local time only when displaying them on screen.

Advertisement

Support JS Mastery Path by checking out our sponsors.