//获取系统时间
var mytime=new Date();
var myyear= mytime.getFullYear();
var mymonth= mytime.getMonth()+1;
var mydate= mytime.getDate();
var myhour= mytime.getHours();
var mymin=mytime.getMinutes();
// var mysec=mytime.getSeconds();
// $(minute_elem).text(minute<10?"0"+minute:minute);//计算分钟
// $(second_elem).text(second<10?"0"+second:second);//计算秒杀
if(mymonth<10){
mymonth="0"+mymonth;
}
if(mydate<10){
mydate="0"+mydate;
}
if(myhour<10){
myhour="0"+myhour;
}
if(mymin<10){
mymin="0"+mymin;
}
var begintime=myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin;
var endtime=myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin;
// $("#begintime").val(myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin);
// $("#endtime").val(myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin);
var mytime=new Date();
var myyear= mytime.getFullYear();
var mymonth= mytime.getMonth()+1;
var mydate= mytime.getDate();
var myhour= mytime.getHours();
var mymin=mytime.getMinutes();
// var mysec=mytime.getSeconds();
// $(minute_elem).text(minute<10?"0"+minute:minute);//计算分钟
// $(second_elem).text(second<10?"0"+second:second);//计算秒杀
if(mymonth<10){
mymonth="0"+mymonth;
}
if(mydate<10){
mydate="0"+mydate;
}
if(myhour<10){
myhour="0"+myhour;
}
if(mymin<10){
mymin="0"+mymin;
}
var begintime=myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin;
var endtime=myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin;
// $("#begintime").val(myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin);
// $("#endtime").val(myyear+"-"+mymonth+"-"+mydate+" "+myhour+":"+mymin);
本文介绍了一种使用JavaScript来获取并格式化当前系统时间的方法。通过简单的脚本实现了时间的获取,并将其格式化为年月日时分的标准格式,便于在网页上显示或用于其他应用程序的时间戳需求。

被折叠的 条评论
为什么被折叠?



