CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C语言

请问C语言中有无获取文件建立日期时间的函数

楼主rebel888(不如归)2004-08-04 13:36:29 在 C/C++ / C语言 提问

昨天晚上那个帖子出BUG了......重新请教  
   
  dir.h中的函数只能显示诸如“11145”之类的时间,但我们要求的是“04-08-03”和“23:12”这种格式的,请问有办法实现吗? 问题点数:50、回复次数:5Top

1 楼BroncoSpeedCoursing(≡野马奔驰≡)回复于 2004-08-04 14:20:12 得分 0

自己编一段程序修改一下结果不行吗?Top

2 楼peter9606( 荷尔蒙一失效 人就清醒了)回复于 2004-08-04 14:23:17 得分 25

time  
  Syntax:       #include   <time.h>  
      time_t   time(   time_t   *time   );  
   
     
   
  The   function   time()   returns   the   current   time,   or   -1   if   there   is   an   error.   If   the   argument   time   is   given,   then   the   current   time   is   stored   in   time.  
   
   
  用time函数得到系统时间  
   
  localtime  
  Syntax:       #include   <time.h>  
      struct   tm   *localtime(   const   time_t   *time   );  
   
     
   
  The   function   localtime()   converts   calendar   time   time   into   local   time.   Warning!  
   
   
  当然了   你需要把得到的一个long   int数字时间转换成一个比较好的格式输出到文档里面,你就用到了上面的转换时间的函数   当然了还有其他很多转换成各种各式的时间函数。  
  Top

3 楼peter9606( 荷尔蒙一失效 人就清醒了)回复于 2004-08-04 14:23:55 得分 25

gmtime  
  Syntax:       #include   <time.h>  
      struct   tm   *gmtime(   const   time_t   *time   );  
   
     
   
  The   gmtime()   function   returns   the   given   time   in   Coordinated   Universal   Time   (usually   Greenwich   mean   time),   unless   it's   not   supported   by   the   system,   in   which   case   NULL   is   returned.   Warning!  
   
  Related   topics:  
  localtime(),   time(),   and   asctime().    
  --------------------------------------------------------------------------------  
   
  localtime  
  Syntax:       #include   <time.h>  
      struct   tm   *localtime(   const   time_t   *time   );  
   
     
   
  The   function   localtime()   converts   calendar   time   time   into   local   time.   Warning!  
   
  Related   topics:  
  gmtime(),   time(),   and   asctime().    
  --------------------------------------------------------------------------------  
   
  mktime  
  Syntax:       #include   <time.h>  
      time_t   mktime(   struct   tm   *time   );  
   
     
   
  The   mktime()   function   converts   the   local   time   in   time   to   calendar   time,   and   returns   it.   If   there   is   an   error,   -1   is   returned.  
   
  Related   topics:  
  time(),   gmtime(),   asctime(),   and   ctime().    
  --------------------------------------------------------------------------------  
   
  strftime  
  Syntax:       #include   <time.h>  
      size_t   strftime(   char   *str,   size_t   maxsize,   const   char   *fmt,   struct   tm   *time   );  
   
     
   
  The   function   strftime()   formats   date   and   time   information   from   time   to   a   format   specified   by   fmt,   then   stores   the   result   in   str   (up   to   maxsize   characters).   Certain   codes   may   be   used   in   fmt   to   specify   different   types   of   time:  
   
  Code   Meaning    
  %a   abbreviated   weekday   name    
  %A   full   weekday   name    
  %b   abbreviated   month   name    
  %B   full   month   name    
  %c   the   standard   date   and   time   string    
  %d   day   of   the   month,   as   a   number   (1-31)    
  %H   hour,   24   hour   format   (0-23)    
  %I   hour,   12   hour   format   (1-12)    
  %j   day   of   the   year,   as   a   number   (1-366)    
  %m   month   as   a   number   (1-12).   Note:   some   versions   of   Microsoft   Visual   C++   may   use   values   that   range   from   0-11.    
  %M   minute   as   a   number   (0-59)    
  %p   locale's   equivalent   of   AM   or   PM    
  %S   second   as   a   number   (0-59)    
  %U   week   of   the   year,   sunday   as   the   first   day    
  %w   weekday   as   a   decimal   (0-6,   sunday=0)    
  %W   week   of   the   year,   monday   as   the   first   day    
  %x   standard   date   string    
  %X   standard   time   string    
  %y   year   in   decimal,   without   the   century   (0-99)    
  %Y   year   in   decimal,   with   the   century    
  %Z   time   zone   name    
  %%   a   percent   sign    
   
  The   strftime()   function   returns   the   number   of   characters   put   into   str,   or   zero   if   an   error   occurs.  
   
  Related   topics:  
  time(),   localtime(),   and   gmtime().Top

4 楼rebel888(不如归)回复于 2004-08-04 23:54:14 得分 0

请问具体应当怎么做?  
   
  比如我include了dir.h头文件后,定义struct   ffblk   ffblk,然后用ffblk.ff_ftime获取了文件建立时间后,怎么用localtime把它转化格式?具体的说,就是请写个实例供我参考一下可否?Top

5 楼rebel888(不如归)回复于 2004-08-05 20:42:54 得分 0

自己顶一下,希望能有人帮助。Top

相关问题

  • 什么函数(或其他方法)可以获取文件名?
  • 怎样获取DLL文件函数的参数信息?
  • 请问,API函数里有可以获取ZIP压缩文件里的文件信息的函数吗?
  • 请问更改文件名的函数,c/c++/winapi
  • 有没有复制文件的C++or C 库函数(急用)
  • gcc中,一个.c文件中的函数,如何调用另一个.c文件中的函数?
  • 标准C 库函数中创建 文件的函数是什么?不是windows函数。(在线)
  • c++builder中用什么函数获取机器的ip地址
  • 标准C里有求文件长度的函数吗?
  • C++中的延时函数delay()在哪个头文件中

关键词

  • 函数
  • 文件
  • 转换
  • localtime
  • gmtime
  • 请问
  • time
  • ffblk
  • asctime
  • strftime

得分解答快速导航

  • 帖主:rebel888
  • peter9606
  • peter9606

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo