Print of Formatted Date (memo)

Here is the code.

#include <time.h>
#include <stdio.h>

#define TIME_SIZE 20

int main() {
  char buffer[TIME_SIZE];
  time_t curtime = time(NULL);
  struct tm* loctime = localtime(&curtime);
  strftime(buffer, TIME_SIZE, "%4Y/%2m/%2d %2H-%2M-%2S ", loctime);
  buffer[TIME_SIZE] = 0;
  printf("The current time is %s\n", buffer);
}

 For the details of Date and Time in C, please refer to 21 Date and Time in The GNU C Library Reference Manual .

你可能感兴趣的:(C++,c,C#)