1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 07:56:23 +00:00

Format minutes & hour with prefixed zero

This commit is contained in:
Loïc Blot (@U-Exp) 2014-09-17 19:54:20 +02:00
parent e800822c37
commit 4dde9f7e08

View File

@ -33,6 +33,8 @@ function fetchConversation(phoneNumber) {
var msgClass = '';
var unixDate = '';
var formatedDate = '';
var formatedHour = '00';
var formatedMin = '00';
var months = ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'Jun.', 'Jul.', 'Aug.', 'Sep.',
'Oct.', 'Nov.', 'Dec.'];
@ -49,8 +51,18 @@ function fetchConversation(phoneNumber) {
// Multiplicate ID to permit date to use it properly
msgDate = new Date(id*1);
formatedHour = msgDate.getHours();
if (formatedHour < 10) {
formatedHour = '0' + formatedHour;
}
formatedMin = msgDate.getMinutes();
if (formatedMin < 10) {
formatedMin = '0' + formatedMin;
}
formatedDate = msgDate.getDate() + " " + months[msgDate.getMonth()-1] + " " +
msgDate.getHours() + ":" + msgDate.getMinutes();
formatedHour + ":" + formatedMin;
conversationBuf += '<div><div class="' + msgClass + '"><div>' +
vals["msg"] + '</div><div class="msg-date">' +