Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1450563
  • 博文数量: 263
  • 博客积分: 10851
  • 博客等级: 上将
  • 技术积分: 2627
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-26 22:40
文章分类

全部博文(263)

文章存档

2013年(4)

2012年(25)

2011年(33)

2010年(50)

2009年(138)

2008年(13)

分类: LINUX

2009-10-30 18:39:34

函数名: localtime

功  能: 把日期和时间转变为结构 
用  法: struct tm *localtime(const time_t *timep); 

函数名:strftime
功  能:格式化日期和时间
用  法:size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);


#include  
#include  

int main(void) 
   time_t timer; 
   struct tm *tblock;
   char cur_date[64];

   /* gets time of day */ 
   time(&timer);

   /* converts date/time to a structure */ 
   tblock = localtime(&timer);

   printf("Local time is: %s", asctime(tblock));
   
   
   /* */
   strftime(cur_date, sizeof(cur_date), "%Y-%m-%d %H:%M:%S", tblock);
   printf("Local time is: %s\n", cur_date);
   

   return 0; 
}

阅读(965) | 评论(0) | 转发(0) |
0

上一篇:目录权限问题

下一篇:字符串函数

给主人留下些什么吧!~~