使用PHP打印JSON时间戳格式

使用PHP打印JSON时间戳格式,php,mysql,json,Php,Mysql,Json,我想将此输出用于我的JSON,如何使用PHP实现此时间戳格式 **This 1403375851930 is not equal to 2015-09-03 11:40:46** {"newsfeed":[{"timeStamp": "1403375851930}]}" 这是我的电流输出 {"newsfeed":[{"0":"54","id":"54","1":"55e869fe755ea8.63620266","unique_id":"55e869fe755ea8.63620266","

我想将此输出用于我的JSON,如何使用PHP实现此时间戳格式

 **This 1403375851930 is not equal to 2015-09-03 11:40:46**

{"newsfeed":[{"timeStamp": "1403375851930}]}"
这是我的电流输出

{"newsfeed":[{"0":"54","id":"54","1":"55e869fe755ea8.63620266","unique_id":"55e869fe755ea8.63620266","2":"News and Events","type":"News and Events","3":"Cosmos","title":"Cosmos","4":"http:\/\/brmhelpdesk.comlu.com\/BRMhelpdesk\/uploads\/cosmos.jpg","image":"http:\/\/brmhelpdesk.comlu.com\/BRMhelpdesk\/uploads\/cosmos.jpg","5":"asd'[sajfpsdgfg\r\nfdfhfgkljghhdsf\r\nasfdjkhjlkjghjhsdfa\r\nasfgfdgjjlkjhgsffsad","description":"asd'[sajfpsdgfg\r\nfdfhfgkljghhdsf\r\nasfdjkhjlkjghjhsdfa\r\nasfgfdgjjlkjhgsffsad","6":"http:\/\/www.brmhelpdesk.comlu.com\/BRMhelpdesk\/uploads\/lugo.png","profilePic":"http:\/\/www.brmhelpdesk.comlu.com\/BRMhelpdesk\/uploads\/lugo.png","7":"2015-09-03 11:40:46","timestamp":"2015-09-03 11:40:46"}]}
{“新闻提要”:[{“时间戳”:“2015-09-03 11:40:46”}}

我的PHP代码

<?php
$query = 'SELECT * FROM newsfeed';
//execute the query using mysql_query
$result = mysql_query($query);
//then using while loop, it will display all the records inside the table
while ($row = mysql_fetch_array($result)) {
$json['newsfeed'][] = $row;
}
?>

实现目标的最简单方法是:

$timestamp = strtotime('2015-09-03 11:40:46');
就你而言:

while ($row = mysql_fetch_array($result)) {
    $row['timestamp'] = strtotime($row['timestamp']);
    $json['newsfeed'][] = $row;
}

在我的循环中,我将声明它们为1乘1,然后再次作为数组打印?谢谢!它起作用了!但我有另一个问题是1970年1月17日印刷的rofl好吧,不管怎样,你回答了我需要的,再次感谢你!