Reputation: 31951
I need to convert the a time measured in milliseconds since the epoch to a boost::posix_time::ptime
. The only function I see is to convert is from_time_t
but that is only in seconds and would lose the milliseconds.
How can I convert from milliseconds since epoch to a ptime type?
Upvotes: 4
Views: 7014
Reputation: 55796
Where ms
is your milliseconds count since the epoch:
ptime epoch_milliseconds_to_ptime(unsigned long int ms)
{
static const ptime epoch(date(1970, 1, 1));
return epoch + milliseconds(ms);
}
Upvotes: 13