2

jquery.timeago.js を使用して日付フィールドを「timeago」形式に変換しようとしています

$("time.timeago").timeago();

var userSpan = document.createElement("span");
userSpan.setAttribute("class", "text-muted");
userSpan.appendChild(document.createTextNode(message.usernameSender +" | "));
var timeTag = document.createElement("time");
timeTag.setAttribute("class", "timeago");
timeTag.setAttribute("datetime",document.createTextNode(message.date));
userSpan.appendChild(timeTag);

この JavaScript は次のコードを生成します

<span class="text-muted">user1 | <time class="timeago" datetime="[object Text]"></time></span>

私の問題は、datetime の結果が [object Text] であることです。

私は何が欠けていますか?

ありがとう

4

1 に答える 1