// date.js
// Illustrates the use of the Date object by
// displaying the parts of a current date and
// using two Date objects to time a calculation
// Get the current date
alert("Start date.js");
var today = new Date();// Fetch the various parts of the date var dateString = today.toLocaleString();
var day = today.getDay();
var month = today.getMonth();
var year = today.getFullYear();
var timeMilliseconds = today.getTime();
var hour = today.getHours();
var minute = today.getMinutes();
var second = today.getSeconds();
var millisecond = today.getMilliseconds();// Display the parts document.write(
"Date: " + dateString + "<br />",
"Day: " + day + "<br />",
"Month: " + month + "<br />",
"Year: " + year + "<br />",
"Time in milliseconds: " + timeMilliseconds + "<br />",
"Hour: " + hour + "<br />",
"Minute: " + minute + "<br />",
"Second: " + second + "<br />",
"Millisecond: " + millisecond + "<br />");
解决方案 »
- 求去标签代码
- 用过jqgrid的来看看
- 一个有点奇怪的问题
- 关于treeview自动展开并选择到相应节点的问题
- 一个奇怪的js问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 怎么获取复选框下面的值
- 学生举手提问了?
- 关于this对像的问题,解决即算分!解决还可另开贴送分!!!
- 我在一个窗口中A,弹出另一个窗口B,然后我在A窗口中的onunload事件中执行"window.opener=null",为何无效???
- Cesium加载cesium 3Dtiles格式模型数据?
- 用iframe 加载 jquery easy UI dataGrid 数据第一次显示不出来
- 简单修改js,
function format_t(t){
var d=new Date(),b;
if(b=t.match(/\d+/g)){
return d.getFullYear()==b[0] && (d.getMonth()+1)==b[1] && d.getDate()==b[2] ? b[3]+":"+b[4] : b[1]+"-"+b[2];
}else{
return "";
}
}
console.log(format_t(t));
function format_t(t){
var d=new Date(),b=t.match(/\d+/g);
return b.length==6 ? (d.getFullYear()==b[0] && (d.getMonth()+1)==b[1] && d.getDate()==b[2] ? b[3]+":"+b[4] : b[1]+"-"+b[2]) : "";
}
console.log(format_t(t));