Created
August 24, 2009 07:01
-
-
Save Superbil/173710 to your computer and use it in GitHub Desktop.
計算已經服役天數
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 計算已經服役天數 */ | |
var now = new Date(); | |
var day = new Date(2009,9-1,1); | |
/* 這個是入伍日期,上面的寫法是:我在 2007 年 10 月 17 入伍 */ | |
day = (now.getTime()- day.getTime())/(24*60*60*1000); | |
/* 現在時間減去入伍時間,為 Unix 系統時間,毫秒 */ | |
day = Math.ceil(day); | |
/*傳回指定數字或運算式的最小整數 */ | |
if (day < 0) | |
document.write("距離國軍Online 登入還有<strong>" + day*-1 + "</strong> 天"); | |
else | |
document.write("已經在國軍Online <strong>" + day + "</strong> 天"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment