C++ Builder 参考手册 ➙ System::Sysutils ➙ DecodeTime
从日期时间类型数值里面解析出时、分、秒、毫秒
头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:
void __fastcall DecodeTime(const System::TDateTime DateTime, System::Word &Hour, System::Word &Min, System::Word &Sec, System::Word &MSec);
参数:
- DateTime:日期时间类型变量;
- Hour:返回时,0 ~ 23;
- Min:返回分,0 ~ 59;
- Sec:返回秒,0 ~ 59;
- MSec:返回毫秒,0 ~ 999;
返回值:
- 无,解析结果通过参数 Hour, Min, Sec, MSec 返回。
例:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
System::TDateTime dt = Sysutils::Now();
unsigned short uHour, uMin, uSec, uMSec;
Sysutils::DecodeTime(dt, uHour, uMin, uSec, uMSec);
UnicodeString s;
s.sprintf(L"现在时间是 %d:%02d:%02d.%03d", uHour, uMin, uSec, uMSec);
Memo1->Lines->Add(s);
}
运行结果:
相关:
- System::Dateutils::DecodeDateTime
- System::Dateutils::EncodeDateTime
- System::Dateutils::TryEncodeDateTime
- System::Dateutils::DateTimeToUnix
- System::Dateutils::UnixToDateTime
- System::Dateutils::YearOf
- System::Dateutils::MonthOf
- System::Dateutils::DayOf
- System::Dateutils::DayOfTheWeek
- System::Dateutils::DayOfTheMonth
- System::Dateutils::DayOfTheYear
- System::Dateutils::HourOf
- System::Dateutils::MinuteOf
- System::Dateutils::SecondOf
- System::Dateutils::MilliSecondOf
- System::Dateutils
- System::Sysutils::DecodeDate
- System::Sysutils::DecodeDateFully
- System::Sysutils::DecodeTime
- System::Sysutils::EncodeDate
- System::Sysutils::EncodeTime
- System::Sysutils::TryEncodeDate
- System::Sysutils::TryEncodeTime
- System::Sysutils::TryStrToDate
- System::Sysutils::TryStrToDateTime
- System::Sysutils::TryStrToTime
- System::Sysutils::FormatDateTime
- System::Sysutils::CurrentYear
- System::Sysutils::Now
- System::Sysutils::Date
- System::Sysutils::Time
- System::Sysutils
C++ Builder 参考手册 ➙ System::Sysutils ➙ DecodeTime