この記事では、JSが現在の時刻を簡単に取得して表示する方法について説明します。次のように、参照のために共有してください。
<!Doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-equiv" content = "text/html; charset = gb2312"/> <pittupl> <titl> date(); var year = now.getTullear(); // year var month = now.getmonth() + 1; //月var day = now.getDate(); // day var hh = now.gethours(); // time var mm = now.getMinutes(); // bar clock = year +" - "; if(month <10)clock += "0"; clock += month +" - "; if(day <10)clock += "0"; if(hh <10) "; if(hh <10)clock +=" 0 " mm; document.write(clock); </script> </body> </html>
PS:JavaScriptの時間と日付の操作に興味がある友人は、このサイトのオンラインツールを参照することもできます。
UNIXタイムスタンプ変換ツール:
http://tools.vevb.com/code/unixtime
世界中のオンライン時間調査:
http://tools.vevb.com/zhuanhuanqi/worldtime
オンライン永久カレンダー:
http://tools.vevb.com/bianmin/wannianli
Web永久カレンダー:
http://tools.vevb.com/bianmin/webwannianli
For more information about JavaScript, please check this site's special topics: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Skills", 「JavaScriptトラバーサルアルゴリズムとスキルの概要」および「JavaScript数学的操作の使用の概要」
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。