Re: [問題] 請問date物件在瀏覽器上有限制嗎?
※ 引述《dedek (我要快樂起來)》之銘言:
: 各位前輩下面一段程式
: endtime這個變數丟給new Date後,在IE6上面執行沒問題,
: 但是到了kkman或是IE7後,丟進去的資料到了 endtimedate就會是空值
: 想了好久 還是找不到原因,所以上來問問前輩
: 請問這要怎麼處理比較好?
: 這段程式最主要是判斷textbox4的日期 不能比textbox3早
: var endtime = document.getElementById("TextBox4").value;
: var starttime = document.getElementById("TextBox3").value;
果然是因為字串格式的問題 , fx 是不吃 yyyy-mm-dd 的 ,
手動自己做個 replace - , / 的行為換成 yyyy/mm/dd 吧。
endtime=endtime.replace(/-/gi,"/");
starttime=starttime.replace(/-/gi,"/");
換完之後如果還有問題再丟新的error format上來.
: var endtimedate = new Date(endtime);
: var starttimedat=new Date(starttime);
: var compare = Date.parse(endtimedate.toString()) - Date.parse(starttimedat.toS
: tring()) - Date.parse(starttimedat.toString());
: var comday = compare / (1000 * 60 * 24*60);
--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 74.207.224.18
推
01/28 11:41, , 1F
01/28 11:41, 1F
推
01/28 11:51, , 2F
01/28 11:51, 2F
→
01/28 11:52, , 3F
01/28 11:52, 3F
→
01/28 11:52, , 4F
01/28 11:52, 4F
推
01/28 15:53, , 5F
01/28 15:53, 5F
→
01/28 15:53, , 6F
01/28 15:53, 6F
→
01/28 15:54, , 7F
01/28 15:54, 7F
推
01/29 22:08, , 8F
01/29 22:08, 8F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章