RAD Studio
ContentsIndex
PreviousUpNext
ctime, _wctime

Header File 

time.h  

Category 

Time and Date Routines 

Prototype 

char *ctime(const time_t *time); 

wchar_t *_wctime(const time_t *time); 

Description 

Converts date and time to a string. 

ctime converts a time value pointed to by time (the value returned by the function time) into a 26-character string in the following form, terminating with a newline character and a null character: 

Mon Nov 21 11:31:54 1983\n\0 

All the fields have constant width. 

The global long variable _timezone contains the difference in seconds between GMT and local standard time (in PST, _timezone is 8*60*60). The global variable _daylight is used to tell the RTL's functions (mktime & localtime) whether they should take daylight saving time into account if it runs into a date that would normally fall into that category. It is set to 1 if the daylight savings time conversion should be applied.. These variables are set by the tzset function, not by the user program directly. 

Return Value 

ctime returns a pointer to the character string containing the date and time. The return value points to static data that is overwritten with each call to ctime. 

Example  

#include <stdio.h>
#include <time.h>
int main(void)
{
  time_t t;
  time(&t);
  printf("Today's date and time: %s\n", ctime(&t));
  return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
ctime 
_wctime 
 
 
 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!