Vc将时间转换为double或者是long型的函数 请问各位大侠,在VC中有没有将时间例如“1900/1/1”转换为long型或者是double型变量的函数?就像VB中的datevalue? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 COleDateTime dt;dt.ParseDateTime("1900/1/1");COleDateTime是一种通用格式,长度好象就是double,可以直接进行数据库存取操作。可以直接与COleDateTimeSpan变量加减操作。如:COleDateTime dtToday = COleDateTime::GetCurrentTime() + COleDateTimeSpan(1,0,0,0);//可以得到明天的值。 SystemTimeToVariantTimeCDateTimeCOleDateTime SystemTimeToVariantTimeCDateTimeCOleDateTime #include <iostream>#include <time.h>using namespace std;int main(void){ char cstr[] = "2000/01/01"; int nYear,nMon,nDay; struct tm t; time_t tt; memset(&t,0,sizeof(struct tm)); sscanf(cstr,"%d/%d/%d",&nYear,&nMon,&nDay); t.tm_year = nYear - 1900; t.tm_mon = nMon; t.tm_mday = nDay; tt = mktime(&t); cout<<tt<<endl; return 0;} 单文档与Fromview区别 批量执行可运行程序 如何为malloc在没有MFC的情况下有memory leak的提示 win9x下为指定进程创建线程 如何将一个对话框复制到另一个VC开发的程序中???????????? 多个工程链接问题 unresolved external symbol c# 调用c写的动态链接库时产生的问题,返回参数为结构,结构返回的值不对? m_bIsInit = TRUE;什么意思? New操作在Release版本中出错了 用过bcg类库的帮帮忙? 关于文档类的几个地方不是很理解 网狐里游戏规则修改的问题,有代码,高手帮看
dt.ParseDateTime("1900/1/1");
COleDateTime是一种通用格式,长度好象就是double,可以直接进行数据库存取操作。可以直接与COleDateTimeSpan变量加减操作。如:
COleDateTime dtToday = COleDateTime::GetCurrentTime() + COleDateTimeSpan(1,0,0,0);
//可以得到明天的值。
CDateTime
COleDateTime
CDateTime
COleDateTime
#include <time.h>using namespace std;int main(void)
{
char cstr[] = "2000/01/01";
int nYear,nMon,nDay;
struct tm t;
time_t tt;
memset(&t,0,sizeof(struct tm));
sscanf(cstr,"%d/%d/%d",&nYear,&nMon,&nDay);
t.tm_year = nYear - 1900;
t.tm_mon = nMon;
t.tm_mday = nDay;
tt = mktime(&t);
cout<<tt<<endl;
return 0;
}