HP C/iX Library Reference Manual (30026-90004)

130 Chapter5
HP C/iX Library Function Descriptions
ctime
ctime
Converts the current time into a 26-character ASCII string of the form
Fri May 11 09:53:03 1984\n\0
where \n is a newline character and \0 is a terminating null character.
Syntax
#include <time.h>
char *ctime(const time_t *
timer
);
Parameters
timer
A pointer to the time to be converted.
Return Value
x A pointer to a 26-byte character string containing the converted time.
Description
The ctime function converts a Coordinated Universal Time (UTC) value (a value
representing the number of elapsed seconds since 00:00:00 UTC January 1, 1970) into a
character string. The returned 26 character time value is adjusted to the time zone
specified by the TZ (Time Zone) environment variable.
By default, ctime adjusts the returned value to the Eastern Standard Time (EST) zone.
You may override this default behavior by using the MPE/iX command SETVAR TZ
name
.
Time zone names, and the format of TZTAB.LIB.SYS file containing time zone offsets from
GMT are listed in appendix A, "Time Zones."
Example
Using time and ctime, you can write a simple date command:
#include <stdio.h>
#include <time.h>
main()
{
char *str, *ctime();
time_t time(), nseconds;
nseconds = time(NULL);
str = ctime(&nseconds);
printf("%s\n", str);
}
See Also
time(), ANSI C 4.12.3.2, POSIX.1 8.1