Date display formating

Dates on my form are displayed as follow:
Sat Feb 14 1959 02:00:00 GMT+0200 (Eastern Europe Standard Time)

how can I change the date display format to only show e.g. 2018/12/30 and not all the details as above mentioned.

Hi etienne,

Use this code snippet to get the date in yyyy/mm/dd format:

let date = new Date();
let day = date.getDate();
let month = date.getMonth()+1;
let year = date.getFullYear();
let dateStr = year + "/" + month + "/" + day;
console.log(dateStr);    // show result in the developers console

I hope this helps.

Yisrael

And another way using built-in Javascript Date() methods:

var today = new Date().toISOString().slice(0,10);
console.log(today);	

Guys, thanks for the comments thus far. the date issue I’m experiencing is on repeater display and display on date info on dynamic pages, without coding is there another way of fixing the date format display on dynamic pages etc.

Hi,
It is not possible without code.
Roi

can i just add a text field and code for it to display the current date upon page load? I am sure I can… going that route doesnt work for me so im missing something. theres not an “app for that?”

Hi,
Like Yisrael wrote above,

$w('#yourText').text = dateStr;

Place it in on the main OnReady function.
Roi

Roi,

I am trying to do this with a repeater element for a persons date of birth.

I added the JS in Yisrael Post to my Page Code. How do i link the repeater element to the JS code?

Regards

Hi,
This video will be useful.
The best method for a repeater in this case in onItemReady
Good luck!
Roi

Hi guys! Don’t know if anyone found their desired solution. I’ve been playing around with the same thing. And I found this other forum thread that presented two viable solutions, one using code, the other not using code! Very detailed. I ended up going with the sans code option, but as a newbie coder, I thought the suggested coding sounded very doable, I may go back later when I have more time to try it with coding!

In case anyone else is still searching for a solution and interested:

I use repeater to show two fields (date type) of a collection.
It shows the following result.
Fri Jun 15 2018 11:30:00 GMT+0800 (China Standard Time)
Fri Jun 15 2018 12:30:00 GMT+0800 (China Standard Time)

Can I just show the hour like 11:30 in the field?
Can I calculate the time difference i.e. 1 hour in another field.
I am using repeater to show the attendance of student.

Thanks
Joe

Refer to the post referred to above: Formatting Date

How do you implement this code with a table that is connected to a dataset? I tried following https://www.wix.com/code/home/forum/community-discussion/date-in-a-table-removing-the-time but I don’t understand how it would work for every item in the table. Is there a loop I am supposed to write and execute this on each item in the table?

What format do you want to display?

@yisrael-wix just the date, no time

@poolshark314 A table displays the date according to the format you choose in the Table Settings panel:

What are you getting in your table display?

@yisrael-wix The only 2 choices are DD/MM/YYYY and MM/DD/YYYY. I chose MM/DD/YYYY, but all of the dates still include the time. I would like to only display the date

@poolshark314 Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor.

@yisrael-wix https://editor.wix.com/html/editor/web/renderer/edit/3ec0c417-366f-4edc-bfeb-957a932a55c8?metaSiteId=308a04ab-a1b4-4720-aa59-9af494bab78b&editorSessionId=41775aec-b6c1-4d99-b2eb-d946125f5c58&referralInfo=dashboard

@poolshark314 OK, so I see what’s going on - sorta. I see it, but I don’t understand. I’ll send this to QA for some help. Meanwhile, you can fix your problem like this…

Disconnect your table from the Tournaments dataset as shown in the screen shot:


Then reconnect it. All of the fields will automatically be added to the table. Delete the fields that you don’t want, and Edit the label of the fields that you do want:


The date field should then display the date, and only the date.

I agree this is strange. As I said, I’m going to report this to QA - and then have a beer. :beers:

I hope this helps,

Yisrael