Format Time in Calculated Field

I have a collection called LocalEvents, I am trying to create a calculated field called eventTime from my startDate (Date/Time) field plus my startTime (Time) field.

My formatting is working on the Date but not the Time field. Could someone please tell me what I an doing wrong.

Thank you!
Sylvia

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
$w.onReady(() => {
    $w('#LocalEvents').onReady(() => {
const eventDate = {
            day: "long",
            month: "short",
            year: "numeric"
        };
const startTime = {
            time: "useAmPmFormat"
        }
const thisItem = $w('#LocalEvents').getCurrentItem();
        $w('#eventDate').text = `${thisItem.startDate}+${thisItem.startTime}`;
    });
});

Just set the time toLocaleTimeString as shown here.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString

Check the links on the left hand side of this page for other methods too for date and time.

Could you please check this link I’m getting an not found error thank you!

@1425club66601

Date​.prototype​.toLocale​Time​String()

Where would I put that in my code?

First answer would be to just put it at the end of your event date line in your code, so something like this for example.

$w('#eventDate').text = `${thisItem.startDate}+${thisItem.startTime}.toLocaleTimeString()`;

If you just use it like this for example, then it will be shown as locale time string in the users own locale.

You can set it up with different options to suit yourself. I have it on a form on my website like this.

"startDate": startDate.toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'})

Or like this for another locale option.

.toLocaleTimeString('en-US');

This will set the local time string to be US English, change the locale options if you want it to be set to your own locale.

Here is a website that lists all of the local options with their abbreviated forms.
http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/viewer.htm#a002613623.htm