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?
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With