[JavaScript-Date物件]Date物件,取得日期的年getFullYear、月getMonth、日getDate
用途:
 
取得日期的年
取得日期的月
取得日期的日
 
說明:
取得日期的年 getFullYear
取得日期的月 getMonth
取得日期的日 getDate
 
程式範例:
<script type ="text/javascript">
//宣告一個日期的變數,並取得現在日期。
var d = new Date();
//將現在日期顯示在頁面上
document.write("日期/時間:");
document.write(d.getFullYear()+"年");
document.write(d.getMonth()+1,"月");
document.write(d.getDate()+"日");
</script>
 
 
測試結果:
 









 















其它文章

arrow
arrow

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()