set-time.js

来自「这是《JavaScript学习源代码》一书的源代码」· JavaScript 代码 · 共 19 行

JS
19
字号
// create a new Date object
var now = new Date();

// store the original date and time information
var orig = "Original :\n " +now.toString()+ "\n\n";

// set new date and time details
now.setDate(21);
now.setMonth(1);
now.setHours(12);
now.setMinutes(30);
now.setSeconds(15);
now.setFullYear(2007);

// store the modified date and time information
var mod = "Modified :\n " + now;

// display original and modified date and times
alert( orig + mod );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?