Vorbly Code | WIX REPEATERS CHANGE DATE / TIME FORMAT

Vorbly <Code>

CODING MADE EASY WITH VORBLY

WIX REPEATERS CHANGE DATE / TIME FORMAT

Need to change the date & time format for your repeater? This tutorial will show you how to customize the date and time format for your Wix Repeater using Wix Code. Display date in US, UK or International date formats. We will provide you with the webpage elements and sample codes required to implement this feature.

THE DEMO

1/1

THE ELEMENTS

The Page

Repeater: #repeater1

  • Date / Time Text: #date

The Database

Create a database: Repeaters (dataset1)

Then link fields to your repeater. For this example, we use Created Date (_createdDate) for the date field in the repeater.

THE CODE

Page Code

// FORMAT: 09:47 | 17 SEP 2018 //

 

function DateFormat() {

 

$w("#repeater1").onItemReady( ($w, itemData, index) => {

const monthNames = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];

const strDate = itemData._createdDate.getDate().toString();

const strMonth = monthNames[itemData._createdDate.getMonth()];

const strYear = itemData._createdDate.getFullYear().toString();

const strHour = ("0" + itemData._createdDate.getHours().toString()).slice(-2);

const strMinute = ("0" + itemData._createdDate.getMinutes().toString()).slice(-2);

 

$w("#date").text = strHour + ":" + strMinute + " | " + strDate + " " + strMonth + " " + strYear;

 

});

}

COMMENTS

I'm a paragraph. Click here to add your own text and edit me. It's easy.

WEB DESIGN & DEVELOPMENT SOLUTIONS

GET PROFESSIONAL HELP