#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和系统时间的使用的更多相关文章

  1. C语言日期时间标准库

    用思维导图整理: 代码: #include <stdio.h> #include <time.h> #include <string.h> int main() { ...

  2. C++时间标准库时间time

    转自:http://www.cnblogs.com/yukaizhao/archive/2011/04/29/cpp_time_system_time.html (玉开) C++标准库中的时间需要引用 ...

  3. C语言获取系统时间的几种方式[转]

    C语言获取系统时间的几种方式 C语言中如何获取时间?精度如何? 1 使用time_t time( time_t * timer ) 精确到秒 2 使用clock_t clock() 得到的是CPU时间 ...

  4. C语言获取系统时间的几种方式

    C语言获取系统时间的几种方式 2009-07-22 11:18:50|  分类: 编程学习 |字号 订阅     C语言中如何获取时间?精度如何? 1 使用time_t time( time_t * ...

  5. Windows的本地时间(LocalTime)、系统时间(SystemTime)、格林威治时间(UTC-Time)、文件时间(FileTime)之间的转换

    今天处理了一个Bug,创建历史数据时脚本函数的起始时间不赋值或者赋0值时,计算引擎推给历史库的UTC时间为-288000000000,一开始以为是bug,经过分析后发现不赋值默认给起始时间赋0值,而此 ...

  6. Windows与Linux/Mac系统时间不一致的解决方法

    Windows与Linux/Mac系统时间不一致的解决方法 分类: linux2012-02-12 14:25 1691人阅读 评论(1) 收藏 举报 windowsubuntusystemlinux ...

  7. 【转】Windows与Linux(Ubuntu)双系统时间不一致的解决方法

    当在嵌入式Linux里面备份文件时候,在备份的时候,PC(win7)和开发板的时间都是9:30,但是在开发板发现文件创建时间是9:30,然后u盘插在PC(win7)上,发现文件创建时间是1:30,为什 ...

  8. linux 系统文件类型、系统安装时间、系统启动时间、系统运行时间、设置及显示时间、系统时间和硬件时间

    系统文件类型: 1) $mout 2) df -l:仅列出本地文件系统:-h (--human-readable):-T:文件系统类型 $df -lhf 3) file -s (--special-f ...

  9. .NET/C# 在代码中测量代码执行耗时的建议(比较系统性能计数器和系统时间)

    我们有很多种方法评估一个方法的执行耗时,比如使用性能分析工具,使用基准性能测试.不过传统的在代码中编写计时的方式依然有效,因为它可以生产环境或用户端得到真实环境下的执行耗时. 如果你希望在 .NET/ ...

随机推荐

  1. C# 文件流基本操作步骤

    private void button1_Click(object sender, EventArgs e) { FileStream fs = new FileStream("123.tx ...

  2. 使用c#检测文件正在被那个进程占用 判断文件是否被占用的两种方法

    C# 判断文件是否被占用的三种方法 using System.IO; using System.Runtime.InteropServices; [DllImport("kernel32.d ...

  3. python使用简单http协议来传送文件

    python使用简单http协议来传送文件!在ubuntu环境下,局域网内可以使用nc来传送文件,也可以使用基于Http协议的方式来下载文件我们可以使用python -m SimpleHTTPServ ...

  4. SQL语句中各种数据类型转换方法总结

    1.Access 每个函数都可以强制将一个表达式转换成某种特定数据类型. 语法 CBool(expression) CByte(expression) CCur(expression) CDate(e ...

  5. hdu 2647 Reward

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2647 Reward Description Dandelion's uncle is a boss o ...

  6. hdu 1250 Hat's Fibonacci

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1250 Hat's Fibonacci Description A Fibonacci sequence ...

  7. Hadoop之Hive自定义函数的陷阱

    A left join B, 这个B会连到A. 如<A1,B>, <A2,B>,在处理第一条记录的时候将B.clear(),则第二条记录的B是[]空的这是自定义UDF函数必须注 ...

  8. 用Swift重写公司OC项目(Day1)--程序的AppIcon与LaunchImage如何设置

    公司之前的APP呢经过了两次重写,都是使用OC由本人独立开发的,不过这些东西我都不好意思说是自己写的,真心的一个字:丑!!! 客观原因来说主要是公司要的特别急,而且注重的是功能而非效果,公司的美工之前 ...

  9. Android实现简单音乐播放器(MediaPlayer)

    Android实现简单音乐播放器(MediaPlayer) 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 实现一个简单的音乐播放器,要求功能 ...

  10. ASCII Table

    ASCII Table ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 0 NUT 32 (space) 64 @ 96 . 1 SOH 33 ! 65 ...