function formatFBTime(fbDate, long) { //2011-02-26T18:04:11+0000 var arrDateTime = fbDate.split("T"); var arrDate = arrDateTime[0].split("-"); var arrTime = arrDateTime[1].split("+")[0].split(":"); var arrDay = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"); var arrMonth = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"); // TODO: Zeitzone hart (++arrTime[0]) var newDate = new Date(arrDate[0], arrDate[1], arrDate[2], ++arrTime[0], arrTime[1], arrTime[2]); var strDay = newDate.getDate() > 10 ? newDate.getDate() : "0" + newDate.getDate(); var strWeekDay = arrDay[newDate.getDay()]; var strMonth = arrMonth[newDate.getMonth() - 1]; var strHours = newDate.getHours() > 10 ? newDate.getHours() : "0" + newDate.getHours(); var strMinutes = newDate.getMinutes() > 10 ? newDate.getMinutes() : "0" + newDate.getMinutes(); if(long) return strWeekDay + ", " + strDay + ". " + strMonth + " " + newDate.getFullYear() + " um " + strHours + ":" + strMinutes; else return strDay + ". " + strMonth + " um " + strHours + ":" + strMinutes; }
Freitag, 1. April 2011
Facebook: created_time mit Javascript formatieren
Abonnieren
Posts (Atom)