/* Date2.C v1.0 * * This program was written to provide a command * line date as the UNIX date command. * * Arizona Department of Transportation * Roadway Design Section * Dean C. Sullinger * dsullinger@dot.state.az.us * Aug. 16, 1995 */ #include #include #include struct tm *newtime; time_t aclock; char a[1024]; char *format; void main( void ) { /* Get time in seconds */ time( &aclock ); /* Convert time to struct tm form */ newtime = localtime( &aclock ); /* Format date as UNIX */ format = "%a %b %d %H:%M:%S %Z %Y"; /* Copy date with new format and print */ strftime(a, sizeof(a), format, localtime(&aclock)); printf("%s\n", a); }