标签:
var date = new Date(); function DateDemo(){ var day; var x = ["星期日", "星期一", "星期二", "星期三","星期四", "星期五", "星期六"]; //var d = new Date(); day = date.getDay(); return(x[day]); } function TimeDemo(){ var h, m; var t = ["上午", "下午"]; h = date.getHours(); m = h -12; return m ? t[1] : t[0]; } alert(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + DateDemo() + " " + TimeDemo() + " " +date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());
alert(date.toLocaleString()); //Date 类型也重写了toLocaleString()、toString()和valueOf()方法; //但这些方法返回的值与其他类型中的方法不同。 //Date 类型的toLocaleString()方法会按照与浏览器设置的地区相适应的格式返回日期和时间 // alert(date.toDateString()); // alert(date.toTimeString()); alert(date.toLocaleDateString() + DateDemo() + date.toLocaleTimeString());
标签:
原文地址:http://www.cnblogs.com/double405/p/5087351.html