GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::ctime(3) C++ Standard Libary std::ctime(3)

std::ctime - std::ctime


Defined in header <ctime>
char* ctime( const std::time_t* time );


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:


Www Mmm dd hh:mm:ss yyyy\n


* Www - the day of the week (one of Mon, Tue, Wed, Thu, Fri, Sat, Sun).
* Mmm - the month (one of Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
Dec).
* dd - the day of the month
* hh - hours
* mm - minutes
* ss - seconds
* yyyy - years


The function does not support localization.


time - pointer to a std::time_t object specifying the time to print


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.


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 behavior may be undefined for the values of std::time_t that result in the
string longer than 25 characters (e.g. year 10000)

// Run this code


#include <ctime>
#include <cstring>
#include <cassert>
#include <iostream>


int main()
{
std::time_t result = std::time(nullptr);
std::cout << std::ctime(&result);


char buffer[32];
std::strncpy(buffer, std::ctime(&result), 26);
assert('\n' == buffer[std::strlen(buffer)-1]);
std::cout << buffer;
}


Mon Oct 11 17:10:55 2021
Mon Oct 11 17:10:55 2021


asctime converts a std::tm object to a textual representation
(function)
strftime converts a std::tm object to custom textual representation
(function)
put_time formats and outputs a date/time value according to the specified format
(C++11) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.