Làm cách nào tôi có thể dịch mã giả này thành js hoạt động [đừng lo lắng về ngày kết thúc đến từ đâu ngoại trừ đó là ngày javascript hợp lệ].
var myEndDateTime = somedate; //somedate is a valid js date
var durationInMinutes = 100; //this can be any number of minutes from 1-7200 (5 days)
//this is the calculation I don't know how to do
var myStartDate = somedate - durationInMuntes;
alert("The event will start on " + myStartDate.toDateString() + " at " + myStartDate.toTimeString());
.getTime(). Ví dụ:var myStartDate = new Date(myEndDateTime.getTime() + durationInMinutes * MS_PER_MINUTE);