I want to display yesterday's date, and day.
Script for today's date:
<script type="text/javascript">
<!--
// Array of day names
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
// Array of month Names
var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var now = new Date();
document.write(dayNames[now.getDay()] + ", " +
monthNames[now.getMonth()] + " " +
now.getDate() + ", " + now.getFullYear());
// -->
</script>
I know that adding a -1 will change the date/year, but it doesn't successfully change the day of the week/month because we have listed the days/months in an array, so there is nothing before Sunday and nothing before January.
How can I display the date from yesterday/however days ago making sure the day and month will change?