C date and time operations

C date and time operations

C date and time operations refer to a group of functions in the standard library of the C programming language implementing date and time manipulation operations.[1]

Contents

Function overview

The C date and time operations are defined in the time.h header file (ctime header in C++).

Time manipulation
difftime - computes the difference between times
time - returns the current time of the system as time since epoch
clock - returns raw processor clock time since the program is started
Format conversions
asctime - converts a tm object to a textual representation
ctime - converts a tm object to a textual representation
strftime - converts a tm object to custom textual representation
wcsftime - converts a tm object to custom wide string textual representation
gmtime - converts time since epoch to calendar time expressed as Universal Coordinated Time
localtime - converts time since epoch to calendar time expressed as local time
mktime - converts calendar time to time since epoch
Constants
CLOCKS_PER_SEC - number of processor clock ticks per second
Types
tm - calendar time type
time_t - time since epoch type
clock_t - process running time

Example

This source code snippet prints the current time to the standard output stream.

#include <stdio.h>
#include <time.h>
 
int main(void)
{
    time_t timer = time(NULL);
    printf("current time is %s", ctime(&timer));
    return 0;
}
 
/*
Output is:
current time is Mon Oct 24 17:57:45 2011
*/

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Linguistic Diversity in Space and Time — [http://books.google.com/books?id=hrT xNaDkgQC printsec=frontcover Linguistic Diversity in Space and Time] (University of Chicago Press, 1992) is linguist Johanna Nichols s best known work, pioneering the use of linguistic typology as a tool for… …   Wikipedia

  • Time — This article is about the measurement. For the magazine, see Time (magazine). For other uses, see Time (disambiguation). The flow of sand in an hourglass can be used to keep track of elapsed time. It also concretely represents the present as… …   Wikipedia

  • Operations Malheur I and Malheur II — Part of Vietnam War Date 11 May Aug 2, 1967 Location Quang Ngai Province Result …   Wikipedia

  • Time Warner — Infobox Company company name =Time Warner Inc. company logo = company type =Public (NYSE|TWX) company slogan = foundation =Merger between Time Inc. and Warner Communications (1990); subsequently purchased by AOL (2001) location =Chicago (main)… …   Wikipedia

  • time — n. & v. n. 1 the indefinite continued progress of existence, events, etc., in past, present, and future regarded as a whole. 2 a the progress of this as affecting persons or things (stood the test of time). b (Time) (in full Father Time) the… …   Useful english dictionary

  • Time in physics — In physics, the treatment of time is a central issue. It has been treated as a question of geometry. One can measure time and treat it as a geometrical dimension, such as length, and perform mathematical operations on it. It is a scalar quantity… …   Wikipedia

  • Atomic bombings of Hiroshima and Nagasaki — Part of the Pacific War, World War II …   Wikipedia

  • Urban search and rescue — also known as USAR, or Urban SAR [In the US due to legal issues involving potential confusion with the United States Army Reserve] involves the location, extrication, and initial medical stabilization of victims trapped in confined spaces.… …   Wikipedia

  • Calendar date — For the use of dates on Wikipedia, see the Manual of Style. A date in a calendar is a reference to a particular day represented within a calendar system. The calendar date allows the specific day to be identified. The number of days between two… …   Wikipedia

  • Operations Krivaja '95 and Stupčanica '95 — Part of the Bosnian War Serbian forces capturing Srebrenica …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”