<tfoot id='fKeIN'></tfoot>
      <i id='fKeIN'><tr id='fKeIN'><dt id='fKeIN'><q id='fKeIN'><span id='fKeIN'><b id='fKeIN'><form id='fKeIN'><ins id='fKeIN'></ins><ul id='fKeIN'></ul><sub id='fKeIN'></sub></form><legend id='fKeIN'></legend><bdo id='fKeIN'><pre id='fKeIN'><center id='fKeIN'></center></pre></bdo></b><th id='fKeIN'></th></span></q></dt></tr></i><div id='fKeIN'><tfoot id='fKeIN'></tfoot><dl id='fKeIN'><fieldset id='fKeIN'></fieldset></dl></div>

        <legend id='fKeIN'><style id='fKeIN'><dir id='fKeIN'><q id='fKeIN'></q></dir></style></legend>
          <bdo id='fKeIN'></bdo><ul id='fKeIN'></ul>
      1. <small id='fKeIN'></small><noframes id='fKeIN'>

      2. C++ chrono系统时间以毫秒为单位,时间操作

        C++ chrono system time in milliseconds, time operations(C++ chrono系统时间以毫秒为单位,时间操作)

              <tbody id='I8VZB'></tbody>
            <tfoot id='I8VZB'></tfoot>
              <bdo id='I8VZB'></bdo><ul id='I8VZB'></ul>
                <i id='I8VZB'><tr id='I8VZB'><dt id='I8VZB'><q id='I8VZB'><span id='I8VZB'><b id='I8VZB'><form id='I8VZB'><ins id='I8VZB'></ins><ul id='I8VZB'></ul><sub id='I8VZB'></sub></form><legend id='I8VZB'></legend><bdo id='I8VZB'><pre id='I8VZB'><center id='I8VZB'></center></pre></bdo></b><th id='I8VZB'></th></span></q></dt></tr></i><div id='I8VZB'><tfoot id='I8VZB'></tfoot><dl id='I8VZB'><fieldset id='I8VZB'></fieldset></dl></div>

                  <small id='I8VZB'></small><noframes id='I8VZB'>

                  <legend id='I8VZB'><style id='I8VZB'><dir id='I8VZB'><q id='I8VZB'></q></dir></style></legend>

                  本文介绍了C++ chrono系统时间以毫秒为单位,时间操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  由于 C++11 的文档不足,我遇到了一个小问题.

                  I've got a small problem caused by insufficient documentation of C++11.

                  我想以毫秒、纳秒或秒为单位获得自纪元以来的时间,然后我必须将该值转换"为另一个分辨率.我可以使用 gettimeofday() 来完成它,但它会很容易,所以我尝试使用 std::chrono 来实现它.

                  I'd like to obtain a time since epoch in milliseconds, or nanoseconds or seconds and then I will have to "cast" this value to another resolution. I can do it using gettimeofday() but it will be to easy, so I tried to achieve it using std::chrono.

                  我试过了:

                  std::chrono::time_point<std::chrono::system_clock> now = 
                      std::chrono::system_clock::now();
                  

                  但是我不知道通过这种方式获得的time_point的分辨率是多少,我不知道如何将这个时间作为一个简单的unsigned long long来获得,我也没有任何概念如何将其转换为另一个分辨率.

                  But I have no idea what is a resolution of obtained in this way time_point, and I don't know how to get this time as a simple unsigned long long, and I haven't any conception how to cast it to another resolution.

                  推荐答案

                  你可以用 时钟的分辨率.要转换为毫秒,请使用 duration_cast:

                  You can do now.time_since_epoch() to get a duration representing the time since the epoch, with the clock's resolution. To convert to milliseconds use duration_cast:

                  auto duration = now.time_since_epoch();
                  auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
                  

                  这篇关于C++ chrono系统时间以毫秒为单位,时间操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)

                      <tbody id='NIVTG'></tbody>
                    1. <small id='NIVTG'></small><noframes id='NIVTG'>

                      <i id='NIVTG'><tr id='NIVTG'><dt id='NIVTG'><q id='NIVTG'><span id='NIVTG'><b id='NIVTG'><form id='NIVTG'><ins id='NIVTG'></ins><ul id='NIVTG'></ul><sub id='NIVTG'></sub></form><legend id='NIVTG'></legend><bdo id='NIVTG'><pre id='NIVTG'><center id='NIVTG'></center></pre></bdo></b><th id='NIVTG'></th></span></q></dt></tr></i><div id='NIVTG'><tfoot id='NIVTG'></tfoot><dl id='NIVTG'><fieldset id='NIVTG'></fieldset></dl></div>
                        <legend id='NIVTG'><style id='NIVTG'><dir id='NIVTG'><q id='NIVTG'></q></dir></style></legend>

                          <tfoot id='NIVTG'></tfoot>

                            <bdo id='NIVTG'></bdo><ul id='NIVTG'></ul>