'Showing Flatpickr dates in local timezone, but sending server UTC?

Here's how I'm setting up Flatpickr:

import flatpickr from 'flatpickr';
import { DateTime } from "luxon";

flatpickr(`#${this.el.id}`, {
    altInput: true,
    altFormat: 'M d Y h:i K',
    formatDate: (date, format, locale) => {
        // ?
    }
});

This sends the datetimes back to my backend as UTC which is fine, but I want to show the datetimes in my users local timezone.

How can I accomplish this with Flatpickr and luxon?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source