Display Date Only

I’m very new in Wix and trying to figure out how to display only the Date field in the display instead of having date and time.

any simple way to do it? kindy assist.

@raymond-wong Hi Raymond: Wix Code is based on javascript so when manipulating data you can use any standard javascript capabilities. MDN’s javascript documentation is a great resource for all kinds of built in javascript functionality.

Date is just one of those areas where you have plenty of options for example assuming you have a standard Date object you can print a date string using toDateString() .

Check out this article for an example of what to do.

Cheers

In addition to what Steve said above:

If you are talking about the date being displayed in the long format on the front-end then you can use split and splice to bring it down to a certain format. Something like the below.

const originalDate = $w("#date").text; //this is your original date format
const newDate = originalDate.split(' ').splice(0, 4).join(' '); //we use split and splice over here to bring it to a desired format
$w('#date').text = newDate; //replace with the new date format

Read more about Splice in JavaScript here
Read more about Split in JavaScript here

Good Luck!

thanks for your info. but I’m still don’t understand it.

I got a date field where I entered the date, and when I display it, it show "Tue Jun 04 2019 00:00:00 GMT+0800 (Hong Kong Standard Time).

What I would like to display is just “Jun 04 2019”

Kindly advice.

the field in my database is “scaaexpriredate”

Many Thanks

Hi Raymond

Can you try to be more specific?

We have given you code and example articles to research.

You need to help us to help you by sharing the code you are using and the url of the page you are using it on. Otherwise we are all guessing and wasting effort :-).

Cheers

Hi Steve,

Thanks for the info and I manage to fix it. and also using a different list display removed the timezone from the display.

Many Thanks

@raymond-wong Good to hear you have solved the issue… Can you share your solution? There may be others in the forum that might benefit from hat you figured out.

Cheers

hey shan could you help me out. I tried to use this code but it’s not working at all. Here is what I’ve tried:

Date i want to format: Tue Feb 26 2019 18:15:08 GMT+0000 (Greenwich Mean Time)

This is the code:

export function reviewsRepeater_itemReady($w, itemData, index) {

let date = itemData._createdDate;
$w(‘#submissionTime’).text = date.tolocalstring()

const originalDate = $w(“#submissionTime”).text;
const newDate = originalDate.split(’ ‘).splice(4, 5).join(’ ‘);
$w(’#submissionTime’).text = newDate;
}

@duncanmaguire I don’t understand your code. Please screenshot your repeater and code and post it in a new post in the forum.

@shantanukumar847

@duncanmaguire
Perhaps you need to revisit how you are using the repeater?
Try changing the $w parameter in your reviewsRepeater_itemReady call to something else like $item. This is a scope parameter and will be confused with the main Wix DOM scope $w.

If this doesn’t work then the date you are getting back in itemData is empty (unlikely) or the toLocaleString() is returning a value you are not expecting so I would use console.log($w(‘#submissionTime’).text) after you assign it to test this theory.

Steve