I have an input field for the start calendar and an input field for the end calendar. We want the default calendar entry field to start 30 days before the current date, and the end calendar entry field should be the current date. Here is my date
var today = new Date(), dd = today.getDate(), mm = today.getMonth(), yyyy = today.getFullYear(), month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October" "November", "December"], startdate = month[mm] + ", " + yyyy.toString();
The end date will look something like this: var enddate = startdate - 30; Obviously this will not work.
Therefore, if the current date is December 30, 2011, I would like the start date to be read on December 1, 2011.
EDIT: My question was answered ... sort of. Date.today(); and Date.today().add(-30); work but I need a date in the format January 13, 2012 . Not Fri Jan 13 2012 10:48:56 GMT -055 (EST) . Any help?
EDIT MORE: At the time of writing, this is 2018. Just use Moment.js . This is the best.
javascript jquery
Jesse Atkinson Jan 12 2018-12-12T00: 00Z
source share