Local time with milliseconds

后端 未结 2 1486
悲&欢浪女
悲&欢浪女 2021-02-19 09:43

how can I get current time with library boost. I can do this:

ptime now = boost::posix_timesecond_clock::local_time();
tm d_tm = to_tm(now);

Bu

2条回答
  •  天命终不由人
    2021-02-19 10:11

    look at boost::posix_time::microsec_clock::local_time()

    #include 
    
    #include 
    
    int
    main()
    {
        boost::posix_time::ptime time = boost::posix_time::microsec_clock::local_time();
        boost::posix_time::time_duration duration( time.time_of_day() );
        std::cout << duration.total_milliseconds() << std::endl;
    
        return 0;
    }
    

提交回复
热议问题