1.使用CTime类   

CString str; //获取系统时间   

CTime tm; tm=CTime::GetCurrentTime();   

str=tm.Format("现在时间是%Y年%m月%d日 %X");

MessageBox(str,NULL,MB_OK);

2: 得到系统时间日期(使用GetLocalTime)  

 

SYSTEMTIME st;   

CString strDate,strTime;   

GetLocalTime(&st);   

strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);   

strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);

3.使用GetTickCount//获取程序运行时间  

 

long t1=GetTickCount();//程序段开始前取得系统运行时间(ms)   

Sleep(500); long t2=GetTickCount();//程序段结束后取得系统运行时间(ms)   

str.Format("time:%dms",t2-t1);//前后之差即 程序运行时间   

AfxMessageBox(str);//获取系统运行时间   

long t=GetTickCount();   

CString str,str1;   

str1.Format("系统已运行 %d时",t/3600000);   

str=str1; t%=3600000;   

str1.Format("%d分",t/60000);   

str+=str1; t%=60000;   

str1.Format("%d秒",t/1000);   

str+=str1; AfxMessageBox(str);

MFC获取系统当前时间的几种方法的更多相关文章

  1. MFC获取系统当前时间

    1.使用CTime类 CString str; //获取系统时间 CTime tm; tm=CTime::GetCurrentTime(); str=tm.Format("现在时间是%Y年% ...

  2. Java基础 - Date的相关使用(获取系统当前时间)

    前言: 在日常Java开发中,常常会使用到Date的相关操作,如:获取当前系统时间.获取当前时间戳.时间戳按指定格式转换成时间等.以前用到的时候,大部分是去网上找,但事后又很快忘记.现为方便自己今后查 ...

  3. T_SQL 获取系统当前时间与明天时间的两种格式

    --获取系统明天的时间 select CONVERT(nvarchar(20),dateadd(d,1,getdate()),120)         2017-01-21 15:04:10 sele ...

  4. android service 样例(电话录音和获取系统当前时间)

    关于android service 的具体解释请參考: android四大组件--android service具体解释.以下将用两个实例具体呈现Android Service的两种实现. 一个是st ...

  5. java获取系统指定时间年月日

    java获取系统指定时间年月日 private String setDateTime(String falg) { Calendar c = Calendar.getInstance(); c.set ...

  6. Unity3D获取系统当前时间,并格式化显示

    Unity 获取系统当前时间,并格式化显示.通过“System.DateTime”获取系统当前的时间,然后通过格式化把获得的时间格式化显示出来,具体如下: 1.打开Unity,新建一个空工程,Unit ...

  7. Oracle,MySQL,sqlserver三大数据库如何获取系统当前时间

    Oracle中如何获取系统当前时间:用SYSDATE() MySQL中获取系统当前时间主要有以下几点: (1)now()函数以('YYYY-MM-dd HH:mm:SS')返回当前的日期时间,可以直接 ...

  8. java 获取系统当前时间并格式化

      java 获取系统当前时间并格式化 CreateTime--2018年5月9日11:41:00 Author:Marydon 实现方式有三种 updateTime--2018年7月23日09点32 ...

  9. 使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期

    1.使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期: 1 var newdate = new Date(); 2 var nowyear = newdat ...

随机推荐

  1. msf命令全集

    一.msfconsole ?   帮助菜单 back 从当前环境返回 banner   显示一个MSF banner cd   切换目录 color   颜色转换 connect   连接一个主机 e ...

  2. 复合sql

    update select update bucp..Core_Flow_Opinion set useruid =(select user_uid from bua..bua_user b wher ...

  3. 第一次作业---安卓开发工具Android studio发展演变

    Android studio2013年由谷歌推出,用于安卓端的开发,我所使用的版本为2015年5月推出的1.3.2. 1.安装.配置.作为麻瓜的我,刚刚接触Android studio时在安装方面走了 ...

  4. php Curl_setop 的学习

    cur_op的学习 ###curl_setopt (int ch, string option, mixed value) option的参数 CURLOPT_INFILESIZE: 当你上传一个文件 ...

  5. 使用github托管代码心

    这次使用github托管代码并没有下载客户端git for windows,而是使用eclipse里面自带的git上传了hello world这个项目,步骤如下: 1.首先创建项目:file-> ...

  6. (转)Java并发编程:volatile关键字解析

    转:http://www.cnblogs.com/dolphin0520/p/3920373.html Java并发编程:volatile关键字解析 volatile这个关键字可能很多朋友都听说过,或 ...

  7. Action+Service +Dao三层的功能划分

    来源:http://blog.csdn.net/inter_peng/article/details/41021727 1. Action/Service/DAO简介: Action是管理业务(Ser ...

  8. card-test

    <!DOCTYPE html><html> <head> <title>test</title> <style type=" ...

  9. nginx 的启动脚本

    下载路径为: wget -q http://www.dwhd.org/script/Nginx-init-CentOS 根据自己的实际环境修改相应的参数 把该脚本放到/etc/rc.d/init.d/ ...

  10. OC基础--内存管理中的@property关键字以及其参数

    在上一篇博客中整理的内存管理,管理类的代码量会感觉很大,而且如果对象多的话,感觉到代码有点冗余.下面就介绍Xcode中为我们自动生成内存管理代码的关键字@property 例如:在Person这个类中 ...