我用过
$collection = $db->mpres_seq ;
$document = array(
"id" => new MongoInt64(1),
"last_executed" => new MongoDate(strtotime("2012-04-01 04:00:00")),
"last_message" => ""
);
$collection->insert($document);
此代码用于插入时间戳数据。现在我想取回它。我想要在 mysql 中使用相同类型(和格式)的 Unix_Timestamp(last_executed)
。我怎样才能做到这一点?
> db.mpres_seq.find().pretty()
{
"_id" : ObjectId("528a3a2af7bde99408000080"),
"id" : NumberLong(1),
"last_executed" : ISODate("2012-04-01T02:00:00Z"),
"last_message" : ""
这是一个示例结果。
最佳答案
您只需使用 mongodate .
For showing a human readable MongoDate, you can use something like this:
<?php
date('Y-M-d h:i:s', $yourDate->sec);
关于php - 从使用 ISODate 保存的 mongodb 数据库获取时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20091262/