系统时间的获取计算实例

有关系统时间的获取计算的三个程序实例供大家参考:
1:

#include "atltime.h"   
#include <iostream>   
using namespace std;  



int _tmain(int argc, _TCHAR* argv[])   
{   
CString strTime;  // 用于将CTime对象格式化为字符串   
// 获取当前时间并保存到curTime   
CTime curTime = CTime::GetCurrentTime();   

int nYear = curTime.GetYear();  // 获取当前年份   
int nMonth = curTime.GetMonth(); // 获取当前月份   
int nDay = curTime.GetDay();   // 获取当前日期   
int nHour = curTime.GetHour();  // 获取当前小时时间   
int nMin = curTime.GetMinute(); // 获取当前分钟时间   
int nSec = curTime.GetSecond(); // 获取当前秒时间   

// 输出当前时间   
cout<<"当前时间:"<<endl;   
cout<<nYear<<"年"<<nMonth<<"月"<<nDay<<"日"<<nHour<<"时"<<nMin<<"分"<<nSec<<"秒"<<endl;   

// 为计算时间差,设定一个起始时间并输出   
CTime startTime = CTime(2010,7,3,<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值