因為一般網路上找到的javascript都只有計算登入次,好像沒有記錄上次登入時間的
所以參考了教學自已寫了一個
----------------------------
<script language=javascript>
<!----
cstr=unescape(document.cookie);
if(cstr.length == 0)
{
now=new Date();
date=now.getYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
now.setTime(now.getTime() + (24 * 60 * 60 * 1000 * 365));
num1=1;
document.cookie="num=" + num1 + "date=" + date + ";expires=" + now.toGMTString()
document.write("您好! 這是您第一次進入本站喔 ^^");
}
else
{
cstrdate=cstr.indexOf("date=");
num1=parseInt(cstr.substring(cstr.indexOf("num=")+4,cstrdate))+1;
document.write("這是您第 " + num1+ " 進入本站! " + "您上次進入時間為 " + cstr.substring(cstrdate+5,cstr.length));
now=new Date();
date=now.getYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
now.setTime(now.getTime() + (24 * 60 * 60 * 1000 * 365));
document.cookie="num=" + num1 + "date=" + date + ";expires=" + now.toGMTString()
}
------->
</script>
----------------------------------

我想請問的是上面紅色的那二段時間的格式,在jsp裡面可以import java.text.SimpleDateFormat來設定像yyyy-MM-dd HH:mm:ss這種格式
但在javascript好像不能 ,有什麼方法可以達到相同的效果嗎??

程式寫的很差,請各位高手不要見笑喔