Use this code snippet to get the date in yyyy/mm/dd format:
let date =newDate();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
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.
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 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:
Hi etienne,
Use this code snippet to get the date in yyyy/mm/dd format:
I hope this helps.
Yisrael
And another way using built-in Javascript Date() methods:
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,
Place it in on the main OnReady function.
Roi
@Roi Bendet I think it should have toString()
$w('#date').text = dateStr.toString();
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:
https://www.wix.com/code/home/forum/questions-answers/formatting-date
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?