【发布时间】:2012-04-04 22:57:26
【问题描述】:
首先感谢您花时间研究这个问题。
我将日期作为 unix 时间戳存储在我的数据库中,当我使用以下方式获取所有信息时:
while($row = mysql_fetch_assoc($result)) {
$posts[] = $row;
}
/* return the posts in the JSON format */
return json_encode($posts);
当我尝试使用以下方法获取日期时,该日期仅作为 unix 时间戳提供:
var postHandler = function(postsJSON) {
$.each(postsJSON,function(i,post) {
alert(post.date);
}
}
有没有办法在通过 JSON 发送之前将其转换为可读日期?甚至之后?
非常感谢您的帮助。
【问题讨论】:
-
这两个答案是否解决了您的问题?
标签: php javascript ajax json date