TypeError: $w(...).getCurrentItem is not a function, for time?

Okay, I’ve read multiple post with that contain problems with this error. . . But none of them solved mines. I followed this tutorial: https://support.wix.com/en/article/velo-formatting-dates
To the absolute best of my abilities, but the error keeps appearing. The code is literally nothing that’s not shown in the tutorial.

What I’m trying to do is to make the text on my schedule (I didn’t use any apps) change to match the users time.

I, also, wish—even though this may not be possible—to have a timezone drop down. Where the user selects their closest timezone and the site changes to match. Can someone help me solve this error first?

// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world

$w.onReady(function () {
// Get the date from the date field of the current item

const date = $w("#text6").getCurrentItem().dateField;
// Set the text element to display the date using the user's settings
$w("#text6").text = date.toLocaleDateString()
const options = {
    day: "numeric",
    month: "short",
    year: "numeric"
};
    // Sets the property of the text element to be a string representing today's date in US English
$w("#text6").text = today.toLocaleDateString("en-US", options);
    // To select an element by ID use: $w("#elementID")

    // Click "Preview" to run your code
});

/**
*   Adds an event handler that runs when an input element's value
 is changed.
*    @param {$w.Event} event
*/
export function dropdown1_change(event) {
    // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
    // Add your code for this event here: 
}

The error is telling you the problem: getCurrentItem() is not a function…

And indeed it is not a function… that belongs to the text element you are trying to use. That function/method belongs to the dataset element, something called:

$w("#dataset")

Then you can retrieve the current item using this method. This way:

const currentItem = $w("#dataset").getCurrentItem()

Chello! That worked thank you so much!

I was wondering if it’s possible to turn Wix Text to be able to change with the selected timezones.

For example, the text is in PDT but the user selects EST as a timezone from a drop down menu. The text turns from 5:00PM to 8:00PM est. Is this possible with Wix and are there tutorials I can follow?

I have code for a dropdown timezone menu, but I’m unsure how to connect it to the code above!

@mossanna13 You can do that with vanilla JavaScript using the toLocaleDateString() and toLocaleTimeString() . You only need to pass the timezone to the date option.

const now = new Date();
const time = now.toLocaleDateString('en-PS', { timeZone: 'Asia/Jerusalem' })