Display Days between Startdate and EndDate

web dev asked on January 7, 2019 17:22

Hello Kentico Team

i want to achieve that ,i want to make a loop inside the html to be able to have the result sperated not together for example the result comes like that

<div class="menu__api">Saturday, January 5, 2019, Sunday, January 6, 2019, Monday, January 7, 2019, Tuesday, January 8, 2019, Wednesday, January 9, 2019, Thursday, January 10, 2019</div>

and i want it like that

<div class="menu__api">Saturday, January 5, 2019</div>
<div class="menu__api">Saturday, January 6, 2019</div>

here is my transformation :

Image

Correct Answer

Zach Perry answered on January 7, 2019 18:23

You will have to do that in your GetDates() function.

You can do something like:

allDates.Add("<div class='menu__api'>"+date.ToLongDateString() + "</div>");

then remove the ", " in your result.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Norris Mildred answered on January 9, 2019 10:29 (last edited on January 10, 2019 07:22)

Thanks for sharing with us. One more thing I would like to share with you.

When giving new Date a string date, the string need to include the timezone, otherwise it will be interpreted differently from browser mcdvoice to other (due to different javascript implementations) and from machine to other (due the difference of the local time zone). thanks.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.