2015-12-25 44 views
1

我從sat24獲得衛星圖像(天氣衛星圖像)的鏈接,但sat24不斷更新UTC中時間戳的圖像時間,例如:201512250445。我想添加一些代碼,以獲得時間戳UTC但時間不斷更新,每15分鐘,例如:​​,201512250445,因爲sat24更新的時間戳每15分鐘UTC時間戳201512250445更新分鐘

我想,但我得到了一個未定義的時間

var region = "" + 'sa' + ""; 
    var imageType = "" + 'visual5HDComplete' + ""; 
    var imageCount = 0 + 10 +0; 
    var allowZoom = 'False' == 'True'; 
    var AmazonUrl = "" + '' + ""; 
    var satbeelden = 0 + 10 + 0; 
     var expDate = new Date(); 

    var minutes = 480; 
    expDate.setTime(expDate.getTime() + (minutes * 60 * 1000)); 
    //(this.refspot4 != null) $.fn.cookie("satrefspot4-v2", this.refspot4.toString(), { expires: expDate, path: '/' }); 
    var zoomX = 0; 
    var zoomY = 0; 
    var iszoom = false; 


    var arrayImageTimes = []; 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
    arrayImageTimes.push("" + minutes + ""); 
+0

不清楚你想要什麼。你想計算在當前時間旁邊的整個四分之一小時的時間戳還是什麼? –

+0

'jquery'與它有什麼關係?另外寫''「+'sa'+」「或'0 + 10 + 0'的含義是什麼? – 6502

+0

@ 6502這個函數在另一個jquery中調用 – user5695030

回答

0

只是正常化是:

var region = 'sa'; 
var imageType = 'visual5HDComplete'; 
var imageCount = 10; 
var allowZoom = false; 
var AmazonUrl = ''; 
var satbeelden = 10; 
var expDate = new Date(); 

var quarter= 15*60*1000; 
var currentTimeMillis = expDate.getTime(); 
var nearestQuarter = Math.round(currentTimeMillis/quarter) * quarter; 

var zoomX = 0; 
var zoomY = 0; 
var iszoom = false; 

var arrayImageTimes = []; 
for (var n = 0; n < 10; n++) { 
    arrayImageTimes.push(nearestQuarter); 
    nearestQuarter += quarter; 
} 

這將使你存儲爲自毫秒爲單位今後十年全季度的數組。

0

此代碼「警報的當前日期與時間的格式,你想看到圓潤〜15分鐘:

var d = new Date(); 
var t = d.getTime(); 
d.setTime(t-t%(1000*60*15)); 
alert(f2(d)); 

function f(n) { return ('0'+n).slice(-2); }; 
function f2(d) { 
    return d.getUTCFullYear()+f(d.getUTCMonth() + 1)+f(d.getUTCDate())+f(d.getUTCHours())+f(d.getUTCMinutes()); 
};