I'm currently working on looping through and displaying some objects on an EJS webpage. I'm looping through all of them fine and displaying all other data, but I am unable to trim the timestamp off of a date attribute I'm trying to display. It will display the whole date without trimming, but when I try to alter the string, nothing displays. Here is the code for that part of the EJS file:
<h1 align = "center"><span class="fa fa-map"></span> View Community Maps</h1><br>
<p align="center">Click on a Community Map below to view the full map.</p><br>
<% for (var i=0; i < Maps.length; i++) { %>
<a href="/viewMap/<%= Maps[i].mapID %>" style="text-decoration: none; color: #333333">
<div class="well" align="center">
<script>
var date = Maps[i].mapDate;
var dateStringNoTime = date.slice(0, 10); //where I'm trying to slice the timestamp
</script>
<h3>Community Map for Floor <%= Maps[i].floorLevel%></h3>
<p><%=Employee.firstName%> <%=Employee.lastName%></p>
<p>Week of <script>dateStringNoTime</script></p> // WILL NOT DISPLAY. Displays as "Week of"
</div>
</a>
<% } %>
Any help or tips would be appreciated. Thanks! :)
像这样的Maps [i] .mapDate.getDate()+“。” + Maps [i] .mapDate.getMonth()+“。” + Maps [i] .mapDate.getFullYear(),但是如果您的month = 1,则您得到0;但是你可以这样做
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.