1.整點時間大小比較 例:08:20:21 和 08:22:23的大小
let z = '20:01:00';let z1 = '10:00:00';
let date = new date();
console.log(date) //fri jul 17 2020 09:54:52 gmt+0800 (中國標準時間)
let a = z.split(":");
let b = z1.split(":");
console.log(a,b)//["20", "01", "00"] (3) ["10", "00", "00"]
console.log(date.sethours(a[0], a[1],a[2]),date.sethours(b[0], b[1]),b[2])
2.日期時間大小比較
var startdate1 ='2012-12-30 00:00:00' ;let start1 = new date(startdate1.replace(/\-/g, "\/"));
var startdate2 ='2012-12-30 13:13:02' ;
let start2 = new date(startdate2.replace(/\-/g, "\/"));
start2 .gettime();// 獲取時間戳 單位毫秒
console.log(start1,start13.當前日期加一天
4.獲取當天
var now = new date();var year = now.getfullyear(); //得到年份
var month = now.getmonth(); //得到月份
var date = now.getdate(); //得到日期
var day = now.getday(); //得到週幾
var hour = now.gethours(); //得到小時
var minu = now.getminutes(); //得到分鐘
var sec = now.getseconds(); //得到秒
month = month + 1;
if (month < 10) month = "0" + month;
if (date < 10) date = "0" + date;
if (hour < 10) hour = "0" + hour;
if (minu < 10) minu = "0" + minu;
if (sec < 10) sec = "0" + sec;
var time = "";
time = year + "-" + month + "-" + date + " " + hour + ":" + minu + ":" + sec;
JS比較時間大小
var yourtime document.getelementbyid begin time value var yourtime 2010 12 10 11 12 yourtime yourtime.replace 替換字元,變成標準格式 var d2 new date 取今天的日期 var d...
js 比較時間大小
js 比較時間大小 js var yourtime document.getelementbyid begin time value var yourtime 2010 12 10 11 12 yourtime yourtime.replace 替換字元,變成標準格式 var d2 new date...
Oracle比較時間大小
1,比較當前時間與指定時間相差分鐘數 select sysdate,sysdate to date 2007 04 03 13 45 39 yyyy mm dd hh24 mi ss from dual 輸出結果 2007 4 4 am 10 45 56 0.875196759259259 sele...