利用Date对象显示当前时间是"*年*月*日-*时*分*秒"
发布网友
发布时间:2022-04-23 03:59
我来回答
共4个回答
热心网友
时间:2022-04-23 05:28
string dt=DateTime.Now.ToString("yyyy年MM月dd日-HH时mm-分ss秒"));
Tostring() 可以写成你任何想要的格式。 只要包含yyyy MM dd HH mm ss 他就会找DateTime对象中的年月日 时分秒 你多练几遍就懂了
热心网友
时间:2022-04-23 06:46
$y= date("Y");
$m = date("m");
$d = date("d");
$test = @$_POST["test"];
$shijian= date('Y-m-d H:i:s',time()+8*3600);
热心网友
时间:2022-04-23 08:21
坑爹
热心网友
时间:2022-04-23 10:12
JS脚本:
function Clock() {
var date = new Date();
this.year = date.getFullYear();
this.month = date.getMonth() + 1;
this.date = date.getDate();
this.day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[date.getDay()];
this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
this.toString = function() {
return "现在是:" + this.year + "年" + this.month + "月" + this.date + "日 " + this.hour + ":" + this.minute + ":" + this.second + " " + this.day;
};
this.toSimpleDate = function() {
return this.year + "-" + this.month + "-" + this.date;
};
this.toDetailDate = function() {
return this.year + "-" + this.month + "-" + this.date + " " + this.hour + ":" + this.minute + ":" + this.second;
};
this.display = function(ele) {
var clock = new Clock();
ele.innerHTML = clock.toString();
window.setTimeout(function() {clock.display(ele);}, 1000);
};
}
前台调用:
<SPAN
id=clock></SPAN>