title: Convert MongoDB BSON ObjectId (oid) to generated time in Objective-C?
body: <p>I've found this:</p>
  
  <p>function: <a href="http://github.com/timburks/NuMongoDB/blob/master/src/bson.c#L128" rel="nofollow noreferrer">http://github.com/timburks/NuMongoDB/blob/master/src/bson.c#L128</a>
  bytes: <a href="http://github.com/timburks/NuMongoDB/blob/master/src/platform_hacks.h#L55" rel="nofollow noreferrer">http://github.com/timburks/NuMongoDB/blob/master/src/platform_hacks.h#L55</a>
  struct: <a href="http://github.com/timburks/NuMongoDB/blob/master/src/bson.h#L70" rel="nofollow noreferrer">http://github.com/timburks/NuMongoDB/blob/master/src/bson.h#L70</a></p>
  
  <p>But how exactly would I use this for my iPhone app that gets the oid as a string from the server and want to extract the created_at timestamp? This is what I have so far. It's an Objective-C method, but can I put c code in my Objective-c .m file?</p>
  
  <pre><code>- timeFromBsonOid:(NSString *)oid {
      time_t out;
      memcpy(&amp;out, oid, 4);
      return out;
  }
  </code></pre>
  
  <p>Matt</p>