/* date.c -- * "Date and Time" * Written by J. Patrick Van Metre for * World Wide Web: Beyond the Basics * CS 6204 at Virginia Polytechnic Institute and State University * * This CGI application displays the current date and time */ #include #include #define STRING_LENGTH 256 void main() { time_t Local; char TimeString[STRING_LENGTH]; /* Output header information (followed by blank line): */ /* MIME type of contents of body */ printf("Content-type: text/html\n\n"); /* Compute local time and store text version in TimeString */ time(&Local); strftime(TimeString, STRING_LENGTH, "It is now %I:%M:%S %p on %A, %e %B, %Y", localtime(&Local)); /* Output body */ printf("\n\n"); printf("\n"); printf("Example 12.2\n"); printf("\n\n"); printf("\n"); printf("%s\n", TimeString); printf("\n\n"); printf("\n"); }