MilliSecondOfTheMonth - C++ Builder

C++ Builder 参考手册 ➙ System::Dateutils ➙ MilliSecondOfTheMonth


这个日期时间在这一个月的第几毫秒

头文件:#include
命名空间:System::Dateutils
函数原型:

unsigned __fastcall MilliSecondOfTheMonth(const System::TDateTime AValue);

参数:

  • AValue:日期时间类型变量;

返回值:

  • 返回值为 AValue 日期时间在这个月的第几毫秒;
  • 另外一个函数 MilliSecondOfTheYear 是一个日期时间在这一年的第几毫秒。

例:用两种方法计算现在是本月的第几毫秒:1:用函数 MilliSecondOfTheMonth;2:利用两个日期相减为双精度浮点数的天数计算毫秒数:

#include 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TDateTime dt = Sysutils::Now();
    Memo1->Lines->Add(L"现在时间 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
    Memo1->Lines->Add(String().sprintf(L"现在是本月的第 %u 毫秒", MilliSecondOfTheMonth(dt)));

    unsigned short iYear = YearOf(dt); // 年
    unsigned short iMonth = MonthOf(dt); // 月
    TDateTime d0 = EncodeDate(iYear, iMonth, 1); // iYear 年 iMonth 月 1 日
    double lfDays = dt - d0; // 现在时间距离本月 1 日的天数,小数,例如 0.5 为 12 小时
    long long llMilliSeconds = lfDays * 24 * 60 * 60 * 1000 + 0.5;
    Memo1->Lines->Add(String().sprintf(L"现在是本月的第 %lld 毫秒", llMilliSeconds));
}

运行结果:


相关:

  • System::Dateutils::DateOf
  • System::Dateutils::DateTimeToUnix
  • System::Dateutils::DayOf
  • System::Dateutils::DayOfTheMonth
  • System::Dateutils::DayOfTheWeek
  • System::Dateutils::DayOfTheYear
  • System::Dateutils::DecodeDateTime
  • System::Dateutils::EncodeDateTime
  • System::Dateutils::HourOf
  • System::Dateutils::HourOfTheMonth
  • System::Dateutils::HourOfTheYear
  • System::Dateutils::IsValidDateMonthWeek
  • System::Dateutils::IsValidDateWeek
  • System::Dateutils::MilliSecondOf
  • System::Dateutils::MilliSecondOfTheYear
  • System::Dateutils::MinuteOf
  • System::Dateutils::MinuteOfTheMonth
  • System::Dateutils::MinuteOfTheYear
  • System::Dateutils::MonthOf
  • System::Dateutils::MonthOfTheYear
  • System::Dateutils::SecondOf
  • System::Dateutils::SecondOfTheMonth
  • System::Dateutils::SecondOfTheYear
  • System::Dateutils::TimeOf
  • System::Dateutils::TryEncodeDateTime
  • System::Dateutils::UnixToDateTime
  • System::Dateutils::WeekOfTheMonth
  • System::Dateutils::WeekOfTheYear
  • System::Dateutils::WeeksInYear
  • System::Dateutils::YearOf
  • System::Dateutils
  • System::Sysutils::CurrentYear
  • System::Sysutils::Date
  • System::Sysutils::DecodeDate
  • System::Sysutils::DecodeDateFully
  • System::Sysutils::DecodeTime
  • System::Sysutils::EncodeDate
  • System::Sysutils::EncodeTime
  • System::Sysutils::FormatDateTime
  • System::Sysutils::Now
  • System::Sysutils::Time
  • System::Sysutils::TryEncodeDate
  • System::Sysutils::TryEncodeTime
  • System::Sysutils::TryStrToDate
  • System::Sysutils::TryStrToDateTime
  • System::Sysutils::TryStrToTime
  • System::Sysutils

C++ Builder 参考手册 ➙ System::Dateutils ➙ MilliSecondOfTheMonth

你可能感兴趣的:(MilliSecondOfTheMonth - C++ Builder)