需要改变当前时间,参考代码
$('#sunlight').click(function(){
var dateVal = $("#selDate").val();
var startTime = new Date(dateVal);
var endTime = new Date(dateVal);
var shour = Number($("#startTime :selected").val());
var ehour = Number($("#endTime :selected").val());
if(shour > ehour) {
return;
}
var nTimer = 0.0;
var nIntervId = setInterval(function() {
if(shour < ehour) {
startTime.setHours(shour);
startTime.setMinutes(nTimer);
viewer.clock.currentTime = Cesium.JulianDate.fromDate(startTime);
nTimer += 10.0;
if(nTimer > 60.0){
shour += 1.0;
nTimer = 0.0;
}
}else {
clearInterval(nIntervId);
}
}, 20);
});