Reputation: 1
I need to insert the current timestamp to mongodb in PHP. I wrote the following code:
date_default_timezone_set('UTC');
$end = new MongoDate(strtotime(date('Y-m-d H:i:s')));
echo $end;
I get the following output:
0.00000000 1379320378
Now I have two questions:
1290932238757
Upvotes: 0
Views: 4715
Reputation: 43884
The MongoDate
object consists of two propeties and this is what you see when you echo
, you actually see the string serialisation of the object in the form of the usec
property. To get the result you want you can do:
$end->sec
Upvotes: 1
Reputation: 39704
Your desired output is a Unix Timestamp concatenated with Swatch Internet time
$timestamp = date('U');
$swatch = date('B');
$now = $timestamp.$swatch;
echo $now; // 1379320935404
Upvotes: 2