C言語で現地の現在時刻を表示する
現地時刻で、現在時刻を表示します。
show_current_local_time.c
#include <stdio.h>
#include <time.h>

/**
 * Show current local time
 * @return none
 */
void showCurrentLocalTime() {
  // Get curret time
  time_t currentTime = time(NULL);
  // Convert to local time
  struct tm* localCurrentTime = localtime(&currentTime);

  // Show current local time
  printf("Current local time is %4d/%02d/%02d %02d:%02d:%02d\n",
         localCurrentTime->tm_year + 1900,
         localCurrentTime->tm_mon + 1,
         localCurrentTime->tm_mday,
         localCurrentTime->tm_hour,
         localCurrentTime->tm_min,
         localCurrentTime->tm_sec);
  return;
}

int main(void) {
  // Show current local time
  showCurrentLocalTime();
  return 0;
}

      
実行結果
$ gcc show_current_local_time.c -o show_current_local_time
$ ./show_current_local_time
Current local time is 2014/12/17 11:52:22