5

I'm using Luxon to show when orders will be processed. If they place an order after business hours 9am-5pm EST, I want to tell them their order will be ready at 2:00pm EST the following day.

    let easternTime = luxon.DateTime.local().setZone('America/New_York');
    let localTime = luxon.DateTime.local();
    // Omitted/Irrelevant Logic to determine if time is after 9am-5pm EST

    console.log("Business closed...turnaround next day");
    console.log(easternTime.toLocal().plus({ day: 1 }).toFormat('EEE, MMM d, 2:00 a ZZZZ'));

If someone see's this message in San Francisco (PST), I'd like the time to read 11:00am PST. How would I go about accomplishing this with Luxon or some other framework?

Thank you!

moamoa
  • 137
  • 1
  • 1
  • 6

2 Answers2

9

Just needed to use the .set({ hour: 14 }) functionality:

console.log(easternTime.set({ hour: 14 }).set({ minutes: 0 }).toLocal().plus({ day: 1 }).toFormat('EEE, MMM d, h:mm a ZZZZ'));
moamoa
  • 137
  • 1
  • 1
  • 6
2

With the Luxon DateTime object you can set time using set

DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 })
molecule
  • 46
  • 3