const sleep = (timeountMS) => new Promise((resolve) => {
    setTimeout(resolve, timeountMS);
    });
    (async () => {
    console.log(‘11111111, ‘ + new Date());
    await sleep(2000);
    console.log(‘22222222, ‘ + new Date());
    await sleep(2000);
    console.log(‘33333333, ‘ + new Date());
    })();


    1. <br />async function formatTime(){<br /> await sleep(500);<br /> if (typeof(sdate)!="undefined"<br /> && typeof(srealtime)!="undefined"<br /> && typeof(edate)!="undefined"<br /> && typeof(erealtime)!="undefined"){<br /> var startdate = sdate + " " +srealtime;<br /> var enddate = edate + " " + erealtime;<br /> duration = getRemainderTime(startdate,enddate);<br /> console.log("duration is "+ duration);<br /> if(duration<0){<br /> $("#duration").css("color","red").html("请选择正确的开始结束时间!");<br /> }else{<br /> $("#duration").css("color","black").html(duration+"天");<br /> }<br /> }<br /> }<br /> function sleep(ms) {<br /> return new Promise(resolve => setTimeout(resolve, ms));<br /> }