139
rated 0 times
[
143]
[
4]
/ answers: 1 / hits: 66124
/ 7 Years ago, wed, february 22, 2017, 12:00:00
I have four fields in a form, some containing an initial date and the end date (dd / mm / yyyy) and the others contain the start time and the end time (hh: ss).
The value of these fields I use to get the date and time with moment.js such as this:
initialdate = moment( $('input#start_date').val(), 'DD/MM/YYYY' );
start_time = moment( $('input#start_time').val(), 'HH:mm');
enddate = moment( $('input#enddate').val(), 'DD/MM/YYYY' );
end_time = moment( $('input#end_time').val(), 'HH:mm');
What I intend is to then get the difference in seconds between the two dates, concatenating the starting date and time and the ending date and time. I have tried to do this, but to no avail:
start = initialdate + start_time;
end = enddate + end_time;
tracker = moment.duration( end.diff(start) ).asSeconds();
More From » date