最佳答案
如何将这些伪代码转换为可用的 JS (不要担心结束日期来自哪里,除非它是一个有效的 JavaScript 日期)。
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 - durationInMinutes;
alert("The event will start on " + myStartDate.toDateString() + " at " + myStartDate.toTimeString());