2013-02-03 53 views
-2

我對JavaScript沒有太多瞭解。所以請幫助我們。如何使用JavaScript進行日期提醒?

如何設置2013年3月1日3:00:00 AM的倒計時?

贊;

日期前:X左天×時間x分鐘

舉辦日期:耶,其3月1日

日期後:你錯過了一天:(

我已經發佈一個問題之前,但我沒有描述得很好。我希望我這樣做時,請幫忙。我真的需要設置一個倒計時在我的網頁(HTML)

+0

在什麼情況下?在網站上?在服務器上?執着? – Zeta

+0

¿作業? – vol7ron

回答

0
var x=new Date(); 
x.setFullYear(2013,2,1); 
var today = new Date(); 

if (x>today) 
    { 
    alert("You missed the day."); 
    } 
else if (x<today) 
    { 
    alert("x day left"); 
    } 
else { 
    alert("This is the day"); 
    } 

你只需要計算X天信用證EFT。

(2013,2,1)表示2013年3月1日的JavaScript。 Reference

+0

謝謝你:)對不起,我要用X做什麼?不熟悉JS –

+0

哦,我的壞。你可以編輯它嗎?我只想要它作爲文本。不警惕:)對不起 –

0

整個互聯網?男人,這是很多的搜索。

This is on the internet, too.

var x=new Date(); 
x.setFullYear(2013,2,1); 
var today = new Date(); 

if (x>today) { 
    alert("Today is before March 1st, 2013"); 
} else { 
    alert("Today is after March 1st, 2013"); 
} 
+0

(2013,3,1)3是四月:) – StarsSky

+0

touche,多數民衆贊成在9點之前回應。 – PlantTheIdea

0

有了這個代碼就可以知道有多少天從DATE1離開日期2

var date1 = new Date("Feb 3 2013 10:49:00"); 
var date2 = new Date("Feb 4 2013 10:49:00"); 

var days = (date2 - date1)/1000/60/60/24; 
document.write("remain " + days + " to <b>" +date2 + "</b>"); 
相關問題