这对你们大多数人来说一定很简单,但对我来说不是,所以任何帮助都将不胜感激。如何更改函数返回部分的变量之一?我只是添加变量clock =并像这样添加下面的if语句吗?
if (ms > than 86400000) {clock = days + " " + hours};
还是这样?
if (ms > than 3600000) return clock : hours + ":" + minutes.
这是我到目前为止所拥有的。
if (DateDiff("ms", now, TestDue) >= 0) {
var Date1 = new Date();
var Date2 = Date.parse(Date1);
var TestLate1 = Date.parse(TestLate);
var TestDue1 = Date.parse(TestDue);
var TestLate2 = convertMS(TestLate1 - Date2).clock;
var TestDue2 = convertMS(TestDue1 - Date2).clock;
var TestDiff = convertMS(TestLate1 - TestDue1).clock;
tto = "../Images/Blue-120-Button.png";
ttt = "Test Start " + TestDue2;
ttm = "../Images/Blue-120-ButtonMouseOver.png";
ttd = "Test will start in " + TestDue2 + ", will be due in " + (TestDiff) + " after that and will be late on " + TestLate + ".";
C3color = "#FFFFFF";
C3Mcolor = "#FFFF00";
ASTRIS = "../Images/BlueTestB.png";
ASTRIS2 = "../Images/BlueTestB2.png";
所以这是我需要在不同时间实现的功能的一部分。
function convertMS(ms) {
days = Math.floor(ms / 86400000), // 1 Day = 86400000 Milliseconds
hours = Math.floor((ms % 86400000) / 3600000), // 1 Hour = 3600000 Milliseconds
minutes = Math.floor((ms % 3600000) / 60000), // 1 Minutes = 60000 Milliseconds
seconds = Math.floor(((ms % 360000) % 60000) / 1000) // 1 Second = 1000 Milliseconds
if (minutes.toString().length == 1) {
minutes = "0" + minutes
};
if (seconds.toString().length == 1) {
seconds = "0" + seconds
};
//need to change the conditions with if statements for clock//
return {
days: days,
hours: hours,
minutes: minutes,
seconds: seconds,
clock: days + " " + hours + ":" + minutes + ":" + seconds
};
}