急,请高手和大家来看看!解决了得100分!其它灌水人只有一分送,望谅!(120分)

  • 主题发起人 主题发起人 PowerCMM
  • 开始时间 开始时间
P

PowerCMM

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在能够得到系统时间,显示格式为年,月,日,小时,分钟,时间,
我怎么把时间修改只显示为年,月,日,小时!
即Delphi中Now可得到年,月,日,小时,分钟,秒,我怎样把Now只显示
年,月,日,小时,请大家帮忙!先谢了!
 
Strips the date portion from a TDateTime value.

Unit

DateUtils

Category

date/time routines

function TimeOf(const AValue: TDateTime): TDateTime;

Description

Call TimeOf to convert a TDateTime value to a TDateTime value that includes only the time information (sets the date portion to 0, which means 12/30/1899).
 
查看帮助里面的 :“Date/time routines”
 
自己组合
DecodeDate(Now,year,month,day);
DecodeTime(Now,hour,min,sec,msec);
s := IntoStr(year) + '年' + inttostr(month) +'月' + inttostr(day) + '日' +inttostr(hour) + '时';
 
这个问题帮助里面有吧。
 
FormatDatetime('YYYY年MM月DD日hh时', now()) 也可以的
 
formatdatetime('yyyy/mm/dd hh',now);
 
FormatDatetime('YYYY"年"MM"月"DD"日"hh"时"', now())
 
查查帮助和函数表,你就会找到答案的。给你答案不如引导你找到答案。:P
 
FormatDatetime('YYYY年MM月DD日hh时', now())
formatdatetime('yyyy/mm/dd hh',now);
FormatDatetime('YYYY"年"MM"月"DD"日"hh"时"', now())
综合了一下。呵呵
另外送你一个函数,api的.在windows下都可以使用。

用C++语言描述一下:

SYSTEMTIME dwTime;
GetLocalTime(&dwTime);
char szTime[50];
sprintf(szTime,,"%d年%d月%d日",dwTime.wYear,dwTime.wMonth,dwTime.wDay);
cout << szTime;

//这样szTime里就保存了你拼接成的时间了
//在哪里都可以使用
 

问题:急,请高手和大家来看看!解决了得100分!其它灌水人只有一分送,望谅! ( 积分:120, 回复:9, 阅读:43 )
分类:数据库-文件型 ( 版主:cAkk, 吴剑明 )
来自:PowerCMM, 时间:2002-3-28 19:32:00, ID:1008751 [显示:小字体 | 大字体]
我现在能够得到系统时间,显示格式为年,月,日,小时,分钟,时间,
我怎么把时间修改只显示为年,月,日,小时!
即Delphi中Now可得到年,月,日,小时,分钟,秒,我怎样把Now只显示
年,月,日,小时,请大家帮忙!先谢了!


来自:taozhiyu, 时间:2002-3-28 19:37:00, ID:1008767
Strips the date portion from a TDateTime value.

Unit

DateUtils

Category

date/time routines

function TimeOf(const AValue: TDateTime): TDateTime;

Description

Call TimeOf to convert a TDateTime value to a TDateTime value that includes only the time information (sets the date portion to 0, which means 12/30/1899).


来自:taozhiyu, 时间:2002-3-28 19:38:00, ID:1008769
查看帮助里面的 :“Date/time routines”


来自:GanQuan, 时间:2002-3-28 19:39:00, ID:1008770
自己组合
DecodeDate(Now,year,month,day);
DecodeTime(Now,hour,min,sec,msec);
s := IntoStr(year) + '年' + inttostr(month) +'月' + inttostr(day) + '日' +inttostr(hour) + '时';



来自:hbezwwl, 时间:2002-3-28 19:45:00, ID:1008781
这个问题帮助里面有吧。


来自:Tintin, 时间:2002-3-28 19:46:00, ID:1008782
FormatDatetime('YYYY年MM月DD日hh时', now()) 也可以的


来自:zxb200, 时间:2002-3-28 19:48:00, ID:1008785
formatdatetime('yyyy/mm/dd hh',now);



来自:kingdeezj, 时间:2002-3-28 19:50:00, ID:1008792
FormatDatetime('YYYY"年"MM"月"DD"日"hh"时"', now())


来自:truecat, 时间:2002-3-28 19:52:00, ID:1008798
查查帮助和函数表,你就会找到答案的。给你答案不如引导你找到答案。:P


来自:慕容乾坤, 时间:2002-3-28 20:24:00, ID:1008862
FormatDatetime('YYYY年MM月DD日hh时', now())
formatdatetime('yyyy/mm/dd hh',now);
FormatDatetime('YYYY"年"MM"月"DD"日"hh"时"', now())
综合了一下。呵呵
另外送你一个函数,api的.在windows下都可以使用。

用C++语言描述一下:

SYSTEMTIME dwTime;
GetLocalTime(&dwTime);
char szTime[50];
sprintf(szTime,,"%d年%d月%d日",dwTime.wYear,dwTime.wMonth,dwTime.wDay);
cout << szTime;


 
上面的方法都可以的,
还有,你可以显示你想要的时间转化字符串,然后截取掉后面不需要的不就可以了?
 
放入Timer组件在OnTimer
中加入GanQuan
的算法
 
formatdatetime最简单。呵呵!
 
FormatDateTime('YYYY-MM-DD HH:MM:SS',Now);
 
谢谢了!
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部