//全局函数
Date
//Date 类的静态方法
Date.parse
Date.UTC
//Date 对象的建立方法
new Date()
new Date(毫秒数)
new Date(标准时间格式字符串)
new Date(年, 月, 日, 时, 分, 秒, 毫秒)
//Date 对象的更多方法
getFullYear (getUTCFullYear)
getMonth (getUTCMonth)
getDate (getUTCDate)
getDay (getUTCDay)
getHours (getUTCHours)
getMinutes (getUTCMinutes)
getSeconds (getUTCSeconds)
getMilliseconds (getUTCMilliseconds)
getTime
getTimezoneOffset
setFullYear (setUTCFullYear)
setMonth (setUTCMonth)
setDate (setUTCDate)
setHours (setUTCHours)
setMinutes (setUTCMinutes)
setSeconds (setUTCSeconds)
setMilliseconds (setUTCMilliseconds)
setTime
toDateString
toTimeString
toUTCString
toLocaleString
toLocaleDateString
toLocaleTimeString
toString
valueOf
--------------------------------------------------------------------------------
根据一个或多个数值建立时间对象, 及本地计时与世界标准计时的区别
--------------------------------------------------------------------------------
//先用最容易理解的方式建立一个时间对象
var d = new Date(2009, 2, 27, 12, 59, 59, 999);
alert(d); //Fri Mar 27 12:59:59 UTC+0800 2009
alert(d.toString()); //Fri Mar 27 12:59:59 UTC+0800 2009
alert(d.toUTCString()); //Fri, 27 Mar 2009 04:59:59 UTC
alert(d.toLocaleString()); //2009年3月27日 12:59:59
alert(d.toDateString()); //Fri Mar 27 2009
alert(d.toLocaleDateString()); //2009年3月27日
alert(d.toTimeString()); //12:59:59 UTC+0800
alert(d.toLocaleTimeString()); //12:59:59
/* 时间在计算机中被记为一个整数, 这是从 UTC 时间的 1970-1-1 0:0:0 到此时间的毫秒数 */
alert(d.valueOf()); //1238129999999
alert(d.getTime()); //1238129999999
/* 获取本地时间和世界标准计时的时差 */
alert(d.getTimezoneOffset()); //-480; 单位是分钟, 也就是 8 小时
/* 直接使用时间值(毫秒数, 譬如上面的: 1238129999999)建立时间对象 */
var d = new Date(1238129999999);
alert(d.toLocaleString()); //2009年3月27日 12:59:59
/* 但建立函数有 2-7 个参数时, 将是根据 "年, 月, 日, 时, 分, 秒, 毫秒" 建立时间 */
d = new Date(2009, 2, 27, 12, 59, 59, 999);
alert(d.toLocaleString()); //2009年3月27日 12:59:59
d = new Date(2009, 2, 27, 12, 59, 59);
alert(d.toLocaleString()); //2009年3月27日 12:59:59
d = new Date(2009, 2, 27, 12, 59);
alert(d.toLocaleString()); //2009年3月27日 12:59:00
d = new Date(2009, 2, 27, 12);
alert(d.toLocaleString()); //2009年3月27日 12:00:00
d = new Date(2009, 2, 27);
alert(d.toLocaleString()); //2009年3月27日 0:00:00
d = new Date(2009, 2);
alert(d.toLocaleString()); //2009年3月1日 0:00:00
/* Date 类的静态函数 UTC 的参数也是和上面一样的 2-7 个, 但 UTC 获取的是个 number */
var n = Date.UTC(2009, 0); //这只是获取了那个表示时间的毫秒数
alert(typeof n); //number
var d = new Date(n); //根据刚刚获取的数、重新建立为时间对象
alert(d.toUTCString()); //Thu, 1 Jan 2009 00:00:00 UTC
alert(d.toLocaleString()); //2009年1月1日 8:00:00
--------------------------------------------------------------------------------
无参数建立的时间对象、和用全局函数 Date 获取的时间的区别
--------------------------------------------------------------------------------
var d1 = new Date(); //返回时间对象
var d2 = Date(); //返回时间字符串
alert(d1); //Fri Feb 27 13:20:58 UTC+0800 2009
alert(d2); //Fri Feb 27 13:20:58 2009
alert(d1.valueOf()); //1235712058340
alert(d2.valueOf()); //Fri Feb 27 13:20:58 2009
alert(typeof d1); //object
alert(typeof d2); //string
//明显看出 d2 只是字符串, 它可以使用 String 类的方法, 而不能使用 Date 类的方法.
--------------------------------------------------------------------------------
使用字符串参数建立时间对象
--------------------------------------------------------------------------------
var d;
d = new Date('Fri Mar 27 12:59:59 UTC+0800 2009');
alert(d.toLocaleString()); //2009年3月27日 12:59:59
d = new Date('Fri Mar 27 12:59:59 2009');
alert(d.toLocaleString()); //2009年3月27日 12:59:59
d = new Date('Fri Mar 27 2009');
alert(d.toLocaleString()); //2009年3月27日 0:00:00
d = new Date('Mar 27 2009');
alert(d.toLocaleString()); //2009年3月27日 0:00:00
/* 可使用 Date() 返回的字符串 */
var ts = Date();
d = new Date(ts);
alert(d.toLocaleString()); //2009年3月27日 14:04:38
/* Date 类的静态函数 parse 也是需要一样的字符参数, 不过它返回的是个数字(那个毫秒数) */
var n;
n = Date.parse('Mar 27 2009');
alert(n); //1238083200000
alert(typeof n); //number
d = new Date(n);
alert(d.toLocaleString()); //March 27, 2009 0:00:00
------------------------- -------------------------------------------------- -----
Get and set respectively: year, month, day, hour, minute, second, millisecond, among which "day of week" can be obtained but cannot be set
---------- -------------------------------------------------- --------------------
var d = new Date(2009, 2, 27, 12, 58, 59, 999);
alert(d .toLocaleString()); //March 27, 2009 0:00:00
alert(d.getFullYear()); //2009
alert(d.getMonth()); //2 ( Starting from 0, 2 refers to March)
alert(d.getDate()); //27
alert(d.getDay()); //5 (Friday)
alert(d.getHours ()); //12
alert(d.getMinutes()); //58
alert(d.getSeconds()); //59
alert(d.getMilliseconds()); / /999 (milliseconds)
d.setFullYear(2010);
d.setMonth(1);
d.setDate(2);
d.setHours(3);
d. setMinutes(4);
d.setSeconds(5);
d.setMilliseconds(6);
alert(d.toLocaleString()); //February 2, 2010 3:04:05
alert(d.getFullYear()); //2010
alert(d.getMonth()); //1 (starting from 0, 1 refers to February)
alert(d.getDate() ); //2
alert(d.getDay()); //2 (Tuesday)
alert(d.getHours()); //3
alert(d.getMinutes()); //4
alert(d.getSeconds()); //5
alert(d.getMilliseconds()); //6 (milliseconds)
/* There is also a setTime */
var d = new Date();
d.setTime(0);
alert(d.toUTCString()); //Thu, 1 Jan 1970 00:00:00 UTC

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Zend Studio 13.0.1
Powerful PHP integrated development environment
