码迷,mamicode.com
首页 > 其他好文 > 详细

时间格式化函数strftime

时间:2017-06-04 21:23:43      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:本地   clu   ret   nbsp   ring   int   style   char   post   

??

#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



时间格式化函数strftime

标签:本地   clu   ret   nbsp   ring   int   style   char   post   

原文地址:http://www.cnblogs.com/claireyuancy/p/6941648.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!