国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript實現的距離現在多長時間后的一個格式化的日期

2019-11-21 01:01:53
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

/**
*
* 返回一個距離現在多長時間后的一個格式化的日期,如2009年9月5日 14:15:23
* 如:現在時間是2009年9月5日 14:15:23 timeLong=10秒 那么返回:2009年9月5日 14:15:33
*
* @param int timeLong 一個
* @param String formatString YYYY-MM-DD hh:mm:ss
*
*/
function getOneFormatDate(timeLong,formatString)
{
timeLong=parseInt(timeLong);
timeLong=timeLong*1000;
var myDate=new Date();
var futureDate=new Date(parseInt(myDate.getTime())+timeLong);
var year=futureDate.getYear();
var month=futureDate.getMonth();
var day=futureDate.getDate();
var hour=futureDate.getHours();
var minute=futureDate.getMinutes();
var second=futureDate.getSeconds();

if(hour<10)
{
hour="0"+hour;
}
if(minute<10)
{
minute="0"+minute;
}
if(second<10)
{
second="0"+second;
}
formatString=formatString.replace("YYYY",year);
formatString=formatString.replace("MM",month);
formatString=formatString.replace("DD",day);
formatString=formatString.replace("hh",hour);
formatString=formatString.replace("mm",minute);
formatString=formatString.replace("ss",second);
return formatString;
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 织金县| 千阳县| 抚州市| 马鞍山市| 四会市| 洪江市| 浦北县| 饶河县| 临澧县| 定西市| 固安县| 桦南县| 政和县| 鄄城县| 崇明县| 盐山县| 德江县| 潼南县| 乌拉特前旗| 繁昌县| 南皮县| 桃园县| 永安市| 赤壁市| 达日县| 新宾| 延寿县| 嘉义县| 定兴县| 景宁| 石棉县| 南城县| 汉沽区| 张家港市| 盐津县| 杭州市| 崇仁县| 祁连县| 昌邑市| 鄢陵县| 南丰县|