-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13_time.c
More file actions
36 lines (30 loc) · 722 Bytes
/
Copy path13_time.c
File metadata and controls
36 lines (30 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// C program to implement
// the above approach
#include <stdio.h>
#include <time.h>
#define SIZE 256
// Driver code
int main(void)
{
char buffer[SIZE];
time_t curtime;
struct tm *loctime;
// Get the current time.
curtime = time(NULL);
// Convert it to local time
// representation.
loctime = localtime(&curtime);
// Print out the date and time
// in the standard format.
fputs(asctime(loctime), stdout);
// Print it out
strftime(buffer, SIZE,
"Today is %A, %B %d.\n",
loctime);
fputs(buffer, stdout);
strftime(buffer, SIZE,
"The time is %I:%M %p.\n",
loctime);
fputs(buffer, stdout);
return 0;
}