Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. int main()
  2. {
  3. const boost::gregorian::date DATE_EPOCH(1970, 1, 1);
  4. const boost::posix_time::ptime PTIME_DATE_EPOCH(DATE_EPOCH);
  5.  
  6. uint64_t time = 1552575540001; // 14 Mar 2019 14:59:00.001
  7. using namespace boost::posix_time;
  8. const ptime posixTime = ptime(PTIME_DATE_EPOCH.date(), milliseconds(time));
  9.  
  10. const std::string mask= "%Y-%m-%dT%H:%M:%SZ";
  11.  
  12. std::ostringstream stream;
  13. stream.imbue(std::locale(stream.getloc(), new time_facet(mask.c_str())));
  14. stream << posixTime;
  15. std::string timeStr = stream.str();
  16. std::cout << timeStr;
  17.  
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement