Ä£¿é»¯Ò²¾ÍÊǽ«Ò»Ð©Í¨ÓõĶ«Î÷³é³öÀ´·Åµ½Ò»¸öÎļþÖУ¬Í¨¹ýmodule.exportsÈ¥±©Â¶½Ó¿Ú¡£ÎÒÃÇÔÚ×î³õн¨ÏîĿʱ¾ÍÓиöutil.jsÎļþ¾ÍÊDZ»Ä£¿é»¯´¦Àíʱ¼äµÄ
- /**
- * ´¦Àí¾ßÌåÒµÎñÂß¼
- */
- function formatTime(date) {
- //»ñÈ¡ÄêÔÂÈÕ
- var year = date.getFullYear()
- var month = date.getMonth() + 1
- var day = date.getDate()
- //»ñȡʱ·ÖÃë
- var hour = date.getHours()
- var minute = date.getMinutes()
- var second = date.getSeconds();
- //¸ñʽ»¯ÈÕÆÚ
- return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
- }
- function formatNumber(n) {
- n = n.toString()
- return n[1] ? n : '0' + n
- }
- /**
- * Ä£¿é»¯µ¼³ö±©Â¶½Ó¿Ú
- */
- module.exports = {
- formatTime: formatTime
- }
ʹÓ÷½Ê½£º
- //µ¼ÈëÄ£¿é»¯·½Ê½
- var util = require('../../utils/util.js')
- Page({
- data: {
- logs: []
- },
- onLoad: function () {
- this.setData({
- logs: (wx.getStorageSync('logs') || []).map(function (log) {
- // ͨ¹ý±©Â¶µÄ½Ó¿Úµ÷ÓÃÄ£¿é»¯·½·¨
- return util.formatTime(new Date(log))
- })
- })
- }
- })
¡¡
1.±¾Õ¾×ñÑÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄÜ»á¾ÎÒÃDZà¼Ð޸Ļò²¹³ä¡£
Ïà¹ØÎÄÕÂ
-
΢ÐÅС³ÌÐò ÂÖ²¥Í¼ swiperͼƬ×é¼þ
2016-11-23 09:49
-
΢ÐÅС³ÌÐò ¿ª·¢ ΢ÐÅ¿ª·¢Õß¹¤¾ß ¿ì½Ý¼ü
2016-11-23 09:49
-
΢ÐÅС³ÌÐò Ò³ÃæÌøת ´«µÝ²ÎÊý
2016-11-23 09:49
-
΢ÐÅС³ÌÐò ÈçºÎ»ñȡʱ¼ä
2016-11-23 09:49
ÍøÓѵãÆÀ
¾«²Êµ¼¶Á
ÈÈÃÅ×ÊѶ
¹Ø×¢ÎÒÃÇ
¹Øע΢ÐŹ«Öںţ¬Á˽â×îо«²ÊÄÚÈÝ