So, I'm a little bit confused by what I'm looking at. I'm converting a MongoDate to JSON using PHP's json_encode
function and built-in MongoDB stuff. The result is this within my JSON string that's returned:
"date":{"sec":1344724737,"usec":0}}
I understand the sec
value is UNIX epoch time (seconds from 00:00:00 UTC on 1 January 1970 to be more precise). However, I don't know what the usec
value is. Is it an unsigned integer value for the milliseconds? Should I be using sec
to get the value? For the record, I'm converting this into an NSDate
in an iOS application. It works that way, but I just like to know more about what these values are to make sure I am using the right one (and so I can sleep at night once it goes into production).
It's an integer corresponding to the number of microseconds (μsec). You divide by 1000000 and add it to the sec
value to get the full timestamp.
usec
means µseconds
, or microseconds. There are 1,000,000 microseconds in a second.