I have a form set-up in such a way that I collect the dates from a different input box and time from a dif
var appointment_date = new Date();
var appointment_start = new Date("Mon Apr 24 2017 20:00:00 GMT-0400 (EDT)");
var appointment_end = new Date("Mon Apr 24 2017 21:30:00 GMT-0400 (EDT)");
console.log(appointment_date);
console.log(appointment_start);
console.log(appointment_end);
 let selected_day = appointment_date.toString().split(' ').slice(0, 1).join(' '),
        selected_date = appointment_date.toString().split(' ').slice(1, 2).join(' '),
        selected_month = appointment_date.toString().split(' ').slice(2, 3).join(' '),
        selected_year = appointment_date.toString().split(' ').slice(3, 4).join(' ');
    console.log(selected_day);
    console.log(selected_date);
    console.log(selected_month);
    console.log(selected_year);
    
 console.log(appointment_start.toString().split(' ').slice(4, appointment_start.toString().length).join(' '));
 console.log(new Date(selected_year, selected_month, selected_date, appointment_start.toString().split(' ').slice(4, appointment_start.toString().length).join(' ')));
    ferent input field.
I tried converting my Date and Time to string; splitting them and then joining it with the other time but it's not giving me the proper time. Is there a better way to do this?
where this.state.appointment_date = new Date();
  this.state.appointment_start = new Date();
  this.state.appointment_end = new Date();
let selected_day = this.state.appointment_date.toString().split(' ').slice(0, 1).join(' '),     // Day
    selected_date = this.state.appointment_date.toString().split(' ').slice(1, 2).join(' '),     // Date
    selected_month = this.state.appointment_date.toString().split(' ').slice(2, 3).join(' '),     // Month
    selected_year = this.state.appointment_date.toString().split(' ').slice(3, 4).join(' ');     // Year
console.log(this.state.appointment_start.setDate(selected_day));  //NaN (output)
console.log(this.state.appointment_start.toString().split(' ').slice(4, this.state.appointment_start.toString().length).join(' ')); // no output
console.log(this.state.appointment_end.toString().split(' ').slice(4, this.state.appointment_end.toString().length).join(' ')); //time
// I tried to create a new date using the above date:
console.log(new Date(selected_day, selected_month, selected_date, selected_year, this.state.appointment_start.toString().split(' ').slice(4, this.state.appointment_start.toString().length).join(' ')));
But I get invalid date for it. Not sure how to do it :/
This way I was trying to break it up and then combine it again to create the final date. But this seems like a really long approach for something which should be simpler
Expected Input/Output:
- Input: dates in the same format as - new Date()
- Output: Take day, month and year from - appointment_dateand time from- appointment_startand create a new date object
 
     
     
    