util.js:
関数transTime(unixtime){ VARの dateTimeに= 新しい日付(のparseInt(unixtime)* 1000年) のvar年= dateTime.getFullYear(); VaRの月= dateTime.getMonth()+ 1 ; VaRの日= dateTime.getDate(); VaRの時間= dateTime.getHours(); VaRの分= dateTime.getMinutes(); VaRの第二= dateTime.getSeconds()。 VAR今= 新しい日付(); VAR now_new = Date.parse(now.toDateString())。 VaRのミリ秒= now_new -日付時刻; VAR timeSpanStr =年+ ' - ' +月+ ' - ' +日+ '' +時間+ ':' +分+ ':' + 秒。 返すtimeSpanStrを。 } module.exportsは = { transTime:transTime }
JSファイル:
// 導入 するvar UTIL =必要(」../../ utilsの/ util.js' ); // 使用 はconsole.log(util.transTime(値));
1