Hello I just need another set of eyes on this. I created this code to set a calendar with the current dates on it, it was working fine but today, sat jan 30, the calendar was still showing it start at sat jan 23.
here is the link to my codepen of it: http://codepen.io/cavascript/pen/MKXrbj
here is the code:
var date = new Date(); var saturday = date.getDate() - date.getDay() - 1; var sunday = date.getDate() - date.getDay() ; var monday = date.getDate() - date.getDay() + 1 ; var tuesday = date.getDate() - date.getDay() + 2 ; var wednesday= date.getDate() - date.getDay() + 3 ; var thursday = date.getDate() - date.getDay() + 4 ; var friday = date.getDate() - date.getDay() + 5 ; var saturday = (new Date(date.setDate(saturday))).toDateString(); var sunday = (new Date(date.setDate(sunday))).toDateString(); var monday = (new Date(date.setDate(monday))).toDateString(); var tuesday = (new Date(date.setDate(tuesday))).toDateString(); var wednesday = (new Date(date.setDate(wednesday))).toDateString(); var thursday = (new Date(date.setDate(thursday))).toDateString(); var friday = (new Date(date.setDate(friday))).toDateString(); //add to html row $('#dateRow').html('<td colspan="4">Date</td><td colspan="4">'+saturday+'</td><td colspan="4">'+sunday+'</td><td colspan ="4">'+monday+'</td><td colspan="4">'+tuesday+'</td><td colspan="4">'+wednesday+'</td><td colspan="4">'+thursday+'</td><td colspan="4">'+friday+'</td><td>Hours</td><td>Delete</td>'); And here is the HTML:
<div class="container-fluid"> <div class="table-responsive"> <table class="table table-bordered"> <tbody> <tr id="dateRow"> </tr> <tr> <td colspan="4">Name</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td colspan="2">Br/lnch</td> <td colspan="2">Dinner</td> <td> </td> <td> </td> </tr> </tbody> </table> </div> Thank you for any input
date.getDate() - date.getDay() - 1...do the math ...30-6-1 = 23