这是我在谷歌浏览器输出: 时间显示楠:楠在Firefox,Chrome浏览器的完美
这是我在Firefox输出:
这是我的函数:
function LoadSessions()
{ //LOAD SESSIONS FROM LOCALSTORAGE
var retrievedObject = localStorage.getItem('session');
// CALL FUNCTION
parsePerObject(JSON.parse(retrievedObject));
function parsePerObject(data)
{
// Turn the data object into an array
var dataArray = [];
$.each(data, function (key, value){
dataArray.push(value);
});
// Sort data by starttime
dataArray.sort(function (a, b) {
if (a.starttime > b.starttime) return 1;
if (a.starttime < b.starttime) return -1;
return 0;
});
// Array with days of the week
var d_names = ["Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"];
// Array with months of the year
var m_names = ["January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December"];
// Variables
var content = "",
dates = [],
date = {};
// LOOP OBJECTS
$.each(dataArray, function(i, item)
{
// Date
var d = new Date(item.starttime);
var year = d.getFullYear();
var month = d.getMonth();
var day = d.getDate();
var da = d.getDay();
date.value = year + "-" + month + "-" + day;
// Startime & endtime
var starttime = new Date(item.starttime);
var endtime = new Date(item.endtime);
var hour_starttime = starttime.getHours();
var min_starttime = starttime.getMinutes();
var hour_endtime = endtime.getHours();
var min_endtime = endtime.getMinutes();
// 12:00 instead of 12:0
if(min_starttime < 10) min_starttime += "0";
if(min_endtime < 10) min_endtime += "0";
// Loop dates
$(date).each(function()
{
// If the date is not in array dates
if($.inArray(date.value, dates) == -1)
{
date.firstchild = item.id;
content = "<div class='span6'><h2 id='" + item.id + "'" + " class='before-blocks'>" + d_names[da] + " " + day + " " + m_names[month] + " " + year + "</h2>";
content += "<ul class='sessionlist blocks unstyled'>";
content += "<li id='item" + item.id + "' class='contentblock has-thumb'>";
content += "<a href='/sessions/view/" + item.id + "'>";
content += hour_starttime + ":" + min_starttime + " - " + hour_endtime + ":" + min_endtime;
content += "<span class='ellipsis name' style='width: 95%;'><b>" + item.name + "</b></span>";
content += "<span class='ellipsis'><em>" + item.speaker + "</em></span></a></li>";
$("#here").append(content);
// Add date to dates
dates.push(date.value);
}
// If the date is in array dates
else
{
var second = "<li id='item" + item.id + "' class='contentblock has-thumb'>";
second += "<a href='/sessions/view/" + item.id + "'>";
second += hour_starttime + ":" + min_starttime + " - " + hour_endtime + ":" + min_endtime;
second += "<span class='ellipsis name' style='width: 95%;'><b>" + item.name + "</b></span>";
second += "<span class='ellipsis'><em>" + item.speaker + "</em></span></a></li>";
$("#item" + date.firstchild).parent().append(second); // Add li to parent (ul) of previous li
}
content = "</ul></div>";
$("#here").append(content);
});
});
}
}
在我的localStorage我有对象是这样的:
{“21216”:{“id”:“21216”,“external_id”:“”,“sessiongroupid”:“1861”,“eventid”:“5588”,“order”:“0” :“RESTful 使用ZF2简化了服务”,“描述”:“需要了解ZF2? “,”starttime“:”2013-01-25 09:00:00“,”endtime“:”2013-01-25 12:30:00“,”speaker“:” Matthew Weier O'Phinney,Rob Allen“,”location“:”Tutorial Room“,”mapid“:”0“,”xpos“:”0.000000“,”ypos“:”0.000000“,”maptype“计划 “ ”IMAGEURL“: ”“, ”演讲“: ”“, ”组织者“: ”0“, ”推特“: ”“, ”allowAddToFavorites“: ”0“, ”allowAddToAgenda“: ”0“,” 票“:” 0" , “URL”: “http://conference.phpbenelux.eu/”, “venueid”: “0”}}
是否anyknow知道为什么我没有得到在Firefox的时间,它表明楠:?NaN的
谢谢!你是最好的! – nielsv 2013-04-26 12:16:05
@ user1775531没问题,很高兴我可以帮忙! – Timespace 2013-04-26 13:24:42