时间格式化函数strftime

来源:互联网 发布:mac版谷歌dhc插件下载 编辑:程序博客网 时间:2024/05/17 00:51


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

int main()
{
  char timebuf[100]={0};
  time_t timep; 
  struct tm *p_tm; 
  
  timep = time(NULL); 
  p_tm = localtime(&timep); /*获取本地时区时间*/
  
  strftime(timebuf, sizeof(timebuf),"%Y-%m-%d %H:%M:%S",p_tm);
  
  printf("%s\n", timebuf);

  return 0;
}

结果:2015-06-12 03:44:54



0 0
原创粉丝点击