⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta name="generator" content=  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">  <title>Standard C Date &amp; Time</title>  <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table>  <tr>  <td>  <div class="body-content">  <div class="header-box">    <a href="../index.html">cppreference.com</a> &gt; <a href=    "index.html">Standard C Date &amp; Time</a>  </div>  <div class="name-format">    asctime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  char *asctime( const struct tm *ptr );</pre>  <p>The function asctime() converts the time in the struct  &#39;ptr&#39; to a character string of the following format:</p>  <pre class="example-code">   day month date hours:minutes:seconds year            </pre>  <p>An example:</p>  <pre class="example-code">   Mon Jun 26 12:03:53 2000             </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="clock.html">clock</a><br>    <a href="ctime.html">ctime</a><br>    <a href="difftime.html">difftime</a><br>    <a href="gmtime.html">gmtime</a><br>    <a href="localtime.html">localtime</a><br>    <a href="mktime.html">mktime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    clock  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  clock_t clock( void );</pre>  <p>The clock() function returns the processor time since the program  started, or -1 if that information is unavailable. To convert the  return value to seconds, divide it by CLOCKS_PER_SEC. (Note: if your  compiler is POSIX compliant, then CLOCKS_PER_SEC is always defined as  1000000.)</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="ctime.html">ctime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    ctime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  char *ctime( const time_t *time );</pre>  <p>The ctime() function converts the calendar time time to local time  of the format:</p>  <pre class="example-code">   day month date hours:minutes:seconds year            </pre>  <p>using ctime() is equivalent to</p>  <pre class="example-code">   asctime( localtime( tp ) );          </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="clock.html">clock</a><br>    <a href="gmtime.html">gmtime</a><br>    <a href="localtime.html">localtime</a><br>    <a href="mktime.html">mktime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    difftime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  double difftime( time_t time2, time_t time1 );</pre>  <p>The function difftime() returns <em>time2</em> - <em>time1</em>,  in seconds.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="gmtime.html">gmtime</a><br>    <a href="localtime.html">localtime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    gmtime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  struct tm *gmtime( const time_t *time );</pre>  <p>The gmtime() function returns the given <em>time</em> in  Coordinated Universal Time (usually Greenwich mean time), unless  it&#39;s not supported by the system, in which case  <strong>NULL</strong> is returned. Watch out for <a href=  "../static_return.html">static return</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="ctime.html">ctime</a><br>    <a href="difftime.html">difftime</a><br>    <a href="localtime.html">localtime</a><br>    <a href="mktime.html">mktime</a><br>    <a href="strftime.html">strftime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    localtime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  struct tm *localtime( const time_t *time );</pre>  <p>The function localtime() converts calendar time time into local  time. Watch out for the <a href="../static_return.html">static  return</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="ctime.html">ctime</a><br>    <a href="difftime.html">difftime</a><br>    <a href="gmtime.html">gmtime</a><br>    <a href="strftime.html">strftime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    mktime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  time_t mktime( struct tm *time );</pre>  <p>The mktime() function converts the local time in <em>time</em> to  calendar time, and returns it. If there is an error, -1 is  returned.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="ctime.html">ctime</a><br>    <a href="gmtime.html">gmtime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    setlocale  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;locale.h&gt;  char *setlocale( int category, const char * locale );</pre>  <p>The setlocale() function is used to set and retrieve the current  locale. If <em>locale</em> is <strong>NULL</strong>, the current  locale is returned. Otherwise, <em>locale</em> is used to set the  locale for the given <em>category</em>.</p>  <p><em>category</em> can have the following values:</p>  <table class="code-table">    <tr>      <th class="code-table-th">Value</th>      <th class="code-table-th">Description</th>    </tr>    <tr>      <td class="code-table-td">LC_ALL</td>      <td class="code-table-td">All of the locale</td>    </tr>    <tr>      <td class="code-table-td">LC_TIME</td>      <td class="code-table-td">Date and time formatting</td>    </tr>    <tr>      <td class="code-table-td">LC_NUMERIC</td>      <td class="code-table-td">Number formatting</td>    </tr>    <tr>      <td class="code-table-td">LC_COLLATE</td>      <td class="code-table-td">String collation and regular expression      matching</td>    </tr>    <tr>      <td class="code-table-td">LC_C<a href=      "../containers.html">TYPE</a></td>      <td class="code-table-td">Regular expression matching,      conversion, case-sensitive comparison, wide character functions,      and character classification.</td>    </tr>    <tr>      <td class="code-table-td">LC_MONETARY</td>      <td class="code-table-td">For monetary formatting</td>    </tr>    <tr>      <td class="code-table-td">LC_MESSAGES</td>      <td class="code-table-td">For natural language messages</td>    </tr>  </table>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    (Standard C String and Character) <a href=    "../stdstring/strcoll.html">strcoll</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strftime  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  size_t strftime( char *str, size_t maxsize, const char *fmt, struct tm *time );</pre>  <p>The function strftime() formats date and time information from  <em>time</em> to a format specified by <em>fmt</em>, then stores the  result in <em>str</em> (up to <em>maxsize</em> characters). Certain  codes may be used in <em>fmt</em> to specify different types of  time:</p>  <table class="code-table">    <tr>      <th class="code-table-th">Code</th>      <th class="code-table-th">Meaning</th>    </tr>    <tr>      <td class="code-table-td">%a</td>      <td class="code-table-td">abbreviated weekday name (e.g.      Fri)</td>    </tr>    <tr>      <td class="code-table-td">%A</td>      <td class="code-table-td">full weekday name (e.g. Friday)</td>    </tr>    <tr>      <td class="code-table-td">%b</td>      <td class="code-table-td">abbreviated month name (e.g. Oct)</td>    </tr>    <tr>      <td class="code-table-td">%B</td>      <td class="code-table-td">full month name (e.g. October)</td>    </tr>    <tr>      <td class="code-table-td">%c</td>      <td class="code-table-td">the standard date and time string</td>    </tr>    <tr>      <td class="code-table-td">%d</td>      <td class="code-table-td">day of the month, as a number      (1-31)</td>    </tr>    <tr>      <td class="code-table-td">%H</td>      <td class="code-table-td">hour, 24 hour format (0-23)</td>    </tr>    <tr>      <td class="code-table-td">%I</td>      <td class="code-table-td">hour, 12 hour format (1-12)</td>    </tr>    <tr>      <td class="code-table-td">%j</td>      <td class="code-table-td">day of the year, as a number      (1-366)</td>    </tr>    <tr>      <td class="code-table-td">%m</td>      <td class="code-table-td">month as a number (1-12). Note: some      versions of Microsoft Visual C++ may use values that range from      0-11.</td>    </tr>    <tr>      <td class="code-table-td">%M</td>      <td class="code-table-td">minute as a number (0-59)</td>    </tr>    <tr>      <td class="code-table-td">%p</td>      <td class="code-table-td">locale&#39;s equivalent of AM or      PM</td>    </tr>    <tr>      <td class="code-table-td">%S</td>      <td class="code-table-td">second as a number (0-59)</td>    </tr>    <tr>      <td class="code-table-td">%U</td>      <td class="code-table-td">week of the year, (0-53), where week 1      has the first Sunday</td>    </tr>    <tr>      <td class="code-table-td">%w</td>      <td class="code-table-td">weekday as a decimal (0-6), where      Sunday is 0</td>    </tr>    <tr>      <td class="code-table-td">%W</td>      <td class="code-table-td">week of the year, (0-53), where week 1      has the first Monday</td>    </tr>    <tr>      <td class="code-table-td">%x</td>      <td class="code-table-td">standard date string</td>    </tr>    <tr>      <td class="code-table-td">%X</td>      <td class="code-table-td">standard time string</td>    </tr>    <tr>      <td class="code-table-td">%y</td>      <td class="code-table-td">year in decimal, without the century      (0-99)</td>    </tr>    <tr>      <td class="code-table-td">%Y</td>      <td class="code-table-td">year in decimal, with the century</td>    </tr>    <tr>      <td class="code-table-td">%Z</td>      <td class="code-table-td">time zone name</td>    </tr>    <tr>      <td class="code-table-td">%%</td>      <td class="code-table-td">a percent sign</td>    </tr>  </table>  <p>The strftime() function returns the number of characters put into  <em>str</em>, or zero if an error occurs.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="gmtime.html">gmtime</a><br>    <a href="localtime.html">localtime</a><br>    <a href="time.html">time</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    time  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;time.h&gt;  time_t time( time_t *time );</pre>  <p>The function time() returns the current time, or -1 if there is an  error. If the argument &#39;time&#39; is given, then the current time  is stored in &#39;time&#39;.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="asctime.html">asctime</a><br>    <a href="clock.html">clock</a><br>    <a href="ctime.html">ctime</a><br>    <a href="difftime.html">difftime</a><br>    <a href="gmtime.html">gmtime</a><br>    <a href="localtime.html">localtime</a><br>    <a href="mktime.html">mktime</a><br>    (Other Standard C Functions) <a href=    "../stdother/srand.html">srand</a><br>    <a href="strftime.html">strftime</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -