std::ctime
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <ctime>
|
||
| char* ctime( const std::time_t* time ); |
||
将已给定的时间,因为时代的日历本地时间,然后到一个文本表示,如果通过调用std::asctime(std::localtime(time))。得到的字符串具有以下格式:
Original:
Converts given time since epoch to a calendar local time and then to a textual representation, as if by calling std::asctime(std::localtime(time)). The resulting string has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Www Mmm dd hh:mm:ss yyyy
Www- 星期几(之一Mon,Tue,Wed,Thu,Fri,Sat,Sun).Original:Www- the day of the week (one ofMon,Tue,Wed,Thu,Fri,Sat,Sun).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.Mmm- 月(之一Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec).Original:Mmm- the month (one ofJan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.dd- 月的一天Original:dd- the day of the monthThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.hh- 小时Original:hh- hoursThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.mm- 分钟Original:mm- minutesThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.ss- 秒Original:ss- secondsThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.yyyy- 年Original:yyyy- yearsThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
功能不支持本地化.
Original:
The function does not support localization.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 参数
| time | - | 指定的时间打印到std::time_t对象的指针
Original: pointer to a std::time_t object specifying the time to print The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
指向一个静态的空字符结尾的字符串的文字表示的日期和时间。
std::asctime和std::ctime之间的字符串可以共享,并在每次调用时可能会被覆盖的任何职能.Original:
Pointer to a static null-terminated character string holding the textual representation of date and time. The string may be shared between
std::asctime and std::ctime, and may be overwritten on each invocation of any of those functions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 注释
这个函数返回一个指向静态数据的指针,是不是线程安全的。此外,它可共享与std::tm和std::gmtime修改静态std::localtime对象。 POSIX标志着这个功能已经过时,并建议std::strftime,而不是.
Original:
This function returns a pointer to static data and is not thread-safe. In addition, it modifies the static std::tm object which may be shared with std::gmtime and std::localtime. POSIX marks this function obsolete and recommends std::strftime instead.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
此行为可能是未定义的time_t的值,结果在超过25个字符的字符串(例如,一年10000)
Original:
The behavior may be undefined for the values of time_t that result in the string longer than 25 characters (e.g. year 10000)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 为例
#include <ctime> #include <iostream> int main() { std::time_t result = std::time(NULL); std::cout << std::ctime(&result); }
Output:
Tue Dec 27 17:21:29 2011
[编辑] 另请参阅
| 一个 tm对象转换为文本表示Original: converts a tm object to a textual representationThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
tm对象转换成自定义的文字表述Original: converts a tm object to custom textual representationThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
| (C++11) |
格式和输出的日期/时间值,按指定的格式 Original: formats and outputs a date/time value according to the specified format The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数模板) |
| C documentation for ctime
| |