C++时间标准库时间time和系统时间的使用
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <windows.h> using namespace std; int main()
{
printf("%s","[time函数]\n");
//time_t是long类型,精确到秒,是当前时间和1970年1月1日零点时间的差
const time_t t = time(NULL); cout<<"current time is "<<t<<endl; /*本地时间:日期,时间 年月日,星期,时分秒*/
struct tm* current_time = localtime(&t);
printf("current year is %d;current month is %d;current date of month is %d\r\n", + current_time->tm_year, + current_time->tm_mon/*此month的范围为0-11*/,current_time->tm_mday); printf("current day of year is %d;current day in week is %d\r\n",
current_time->tm_yday,/*当前日期是今年的第多少天[0,365] */
current_time->tm_wday/*days since Sunday - [0,6] */); printf("time part %d:%d:%d \r\n",
current_time->tm_hour,
current_time->tm_min,
current_time->tm_sec); printf("本地时间:%d-%d-%d %d:%d:%d\r\n",
current_time->tm_year + ,
current_time->tm_mon + ,
current_time->tm_mday,
current_time->tm_hour,
current_time->tm_min,
current_time->tm_sec); /*格林威治时间*/
struct tm* current_gmtime = gmtime(&t); printf("格林威治时间:%d-%d-%d %d:%d:%d\r\n",
current_gmtime->tm_year + ,
current_gmtime->tm_mon + ,
current_gmtime->tm_mday,
current_gmtime->tm_hour,
current_gmtime->tm_min,
current_gmtime->tm_sec); cout <<'\n'<<endl;
cout <<'\n'<<endl; printf("%s","[系统时间]\n"); //声明变量
SYSTEMTIME sys_time; //将变量值设置为本地时间
GetLocalTime( &sys_time ); //输出时间
printf( "%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d\n",sys_time.wYear,
sys_time.wMonth,
sys_time.wDay,
sys_time.wHour,
sys_time.wMinute,
sys_time.wSecond,
sys_time.wMilliseconds,
sys_time.wDayOfWeek); //system("time"); system("pause"); return ;
}
C++时间标准库时间time和系统时间的使用的更多相关文章
- C语言日期时间标准库
用思维导图整理: 代码: #include <stdio.h> #include <time.h> #include <string.h> int main() { ...
- C++时间标准库时间time
转自:http://www.cnblogs.com/yukaizhao/archive/2011/04/29/cpp_time_system_time.html (玉开) C++标准库中的时间需要引用 ...
- C语言获取系统时间的几种方式[转]
C语言获取系统时间的几种方式 C语言中如何获取时间?精度如何? 1 使用time_t time( time_t * timer ) 精确到秒 2 使用clock_t clock() 得到的是CPU时间 ...
- C语言获取系统时间的几种方式
C语言获取系统时间的几种方式 2009-07-22 11:18:50| 分类: 编程学习 |字号 订阅 C语言中如何获取时间?精度如何? 1 使用time_t time( time_t * ...
- Windows的本地时间(LocalTime)、系统时间(SystemTime)、格林威治时间(UTC-Time)、文件时间(FileTime)之间的转换
今天处理了一个Bug,创建历史数据时脚本函数的起始时间不赋值或者赋0值时,计算引擎推给历史库的UTC时间为-288000000000,一开始以为是bug,经过分析后发现不赋值默认给起始时间赋0值,而此 ...
- Windows与Linux/Mac系统时间不一致的解决方法
Windows与Linux/Mac系统时间不一致的解决方法 分类: linux2012-02-12 14:25 1691人阅读 评论(1) 收藏 举报 windowsubuntusystemlinux ...
- 【转】Windows与Linux(Ubuntu)双系统时间不一致的解决方法
当在嵌入式Linux里面备份文件时候,在备份的时候,PC(win7)和开发板的时间都是9:30,但是在开发板发现文件创建时间是9:30,然后u盘插在PC(win7)上,发现文件创建时间是1:30,为什 ...
- linux 系统文件类型、系统安装时间、系统启动时间、系统运行时间、设置及显示时间、系统时间和硬件时间
系统文件类型: 1) $mout 2) df -l:仅列出本地文件系统:-h (--human-readable):-T:文件系统类型 $df -lhf 3) file -s (--special-f ...
- .NET/C# 在代码中测量代码执行耗时的建议(比较系统性能计数器和系统时间)
我们有很多种方法评估一个方法的执行耗时,比如使用性能分析工具,使用基准性能测试.不过传统的在代码中编写计时的方式依然有效,因为它可以生产环境或用户端得到真实环境下的执行耗时. 如果你希望在 .NET/ ...
随机推荐
- 10-排序5 PAT Judge
用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...
- openerp 经典收藏 记录规则 – 销售只能看到自己的客户,经理可以看到全部(转载)
记录规则 – 销售只能看到自己的客户,经理可以看到全部 原文地址:http://cn.openerp.cn/record_rule/ OpenERP中的权限管理有四个层次: 菜单级别: 即,不属于指定 ...
- moses:processPhraseTable被删除
今年一月,processPhraseTable被删除了,具体原因如下: https://www.mail-archive.com/moses-support@mit.edu/msg11372.html ...
- Ubuntu 修改用户密码与启动root账号
passwd sban 修改当前帐号 sudo passwd root 修改root帐号 修改/etc/ssh/sshd_config,改: PermitRootLogin without-passw ...
- urllib3 ProxyManager
ProxyManager is an HTTP proxy-aware subclass of PoolManager. It produces a singleHTTPConnectionPool ...
- A taste of urllib3
import urllib3 import certifi http = urllib3.PoolManager( cert_reqs='CERT_REQUIRED', # Force certifi ...
- 替换APK中的jar包文件
[Qboy] 2014年12月21日 这几天,我第一次做的android游戏(WE!青春纪)马上就要上线.上线之前需要把各个渠道的SDK加入到我们游戏中,与渠道进行联运.但是商务很给力,一下子联系了1 ...
- 在本地环境用虚拟机win2008 sever搭建VS2013 + SVN 代码版本控制环境
此文仅仅是自己笔记做个备忘.因为自己开发一些中小型的软件经常需要修修改改,特别是winform界面的大改动.经常需要对版本进行管理.而租用分布式服务器和远程服务器都不是自己想要的.本文结合虚拟机 + ...
- Leetcode Variant-Plus N
Given a non-negative number represented as an array of digits, plus N to the number. The digits are ...
- elasticsearch查询之term,range,prefix
荒废了很久的博客园,现在又回来了.233333 最近在研究elasticsearch 日志查询: 1.term:代表完全匹配,即不进行分词器分析,文档中必须包含整个搜索的词汇 2.range:主要是对 ...