C++ builder 时间相加减
已知一个字符串,UnicodeString time = "2011/11/04 11:00:00.169";
还已知一个相对时间,毫秒 300 毫秒,
把它们相加之后等于多少啊?
C++ builder里面有这种函数么? C# 里的
DateTime timeStart = new DateTime.Now();
time = timeStart.AddMilliseconds(1000);
[解决办法]
TDateTime dt;
dt = Now();
dt = IncMilliSecond(dt,300);
[解决办法]
这里非常抱歉,由个地方我写错了,导致你也跟着错。那个格式后面改一下。还有就是那个时间要累加,再有,这么着转成csv在excel里面打开是看不到后面的毫秒的,就算你设置个时间格式也不行。只能当成文本来处理。
TStringList *lst = new TStringList();
TDateTime fileTime = StrToDateTime("2011-11-07 15:22:35");
UnicodeString timeOut;
for(int infoCount = 0; infoCount < 6000; infoCount++){
timeOut = FormatDateTime("yyyy-mm-dd hh:nn:ss.zzz",fileTime);
fileTime = IncMilliSecond(fileTime,10);
lst->Add(timeOut);
}
lst->SaveToFile("D:\\test.csv");
delete lst;
TStringList *lst = new TStringList();
TDateTime fileTime = "2011/11/07 15:22:35";
UnicodeString timeOut;
for(int infoCount = 0; infoCount < 6000; infoCount++)
{
fileTime=IncMilliSecond(fileTime,StrToInt64(Info->offsetTime))
timeOut = FormatDateTime("yyyy/mm/dd hh:nn:ss.zzz",fileTime);
lst->Add(timeOut);
}
lst->SaveToFile("D:\\test.csv");
delete lst;