#include <stdio.h>
#include <time.h>
#include <string>
#include <windows.h>
using namespace std; void main()
{
//精确到秒
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime ); char imgeName[] = {};
sprintf(imgeName,
"当前时间:%4d%02d%02d%02d%02d%02d",
+timeinfo->tm_year,
+timeinfo->tm_mon,
timeinfo->tm_mday,
timeinfo->tm_hour,
timeinfo->tm_min,
timeinfo->tm_sec); //imgeName = 0x00d4f908 "当前时间:20150804164416" //精确到毫秒
SYSTEMTIME currentTime;
GetSystemTime(&currentTime);
printf("time: %u/%u/%u %u:%u:%u:%u %d\n",
currentTime.wYear,currentTime.wMonth,currentTime.wDay,
currentTime.wHour,currentTime.wMinute,currentTime.wSecond,
currentTime.wMilliseconds,currentTime.wDayOfWeek); /*
wYear 2015 unsigned short
wMonth 8 unsigned short
wDayOfWeek 2 unsigned short
wDay 4 unsigned short
wHour 9 unsigned short
wMinute 31 unsigned short
wSecond 33 unsigned short
wMilliseconds 149 unsigned short
*/ exit(); }

参考:http://zhidao.baidu.com/link?url=NhiAk1VJdL0X6abaisbuvFy7BmuaWLwp4-TedKdGp045XqXKWIMKnpukvyxsK4DxORdzHkoU_y_iHxQP3GD5-q

http://blog.csdn.net/witxjp/article/details/8079751

C获取当前时间的更多相关文章

  1. iOS中获取当前时间,设定时间,并算出差值

    NSDate *date = [NSDate date];//获取当前时间 NSTimeZone *zone = [NSTimeZone systemTimeZone];//修改时区 NSIntege ...

  2. Js获取当前日期时间及其它操作

    Js获取当前日期时间及其它操作var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份 ...

  3. 【转】Js获取当前日期时间及格式化操作

    (转自:http://www.cnblogs.com/qinpengming/archive/2012/12/03/2800002.html) var myDate = new Date(); myD ...

  4. PHP 获取中国时间,即上海时区时间

    /** * 获取中国时间,即上海时区时间 * @param <type> $format * @return <type> */ function getChinaTime($ ...

  5. C#获取北京时间与设置系统时间

    获取北京时间 public static DateTime GetBeijingTime() { DateTime dt; // 返回国际标准时间 // 只使用 timeServers 的 IP 地址 ...

  6. jquery 获取日期时间

    获取JavaScript 的时间使用内置的Date函数完成 var mydate = new Date();mydate.getYear(); //获取当前年份(2位)mydate.getFullYe ...

  7. 使用 jquery 获取当前时间的方法

    我们在写一些效果时,经常要用到 jquery 获取当前时间,但是jquery 目前并没有提供直接获取当前时间的 api 或者函数,所以我们还是得用原生的 javascript 时间对象 Date 来获 ...

  8. java学习第13天( java获取当前时间,有关大数据的运算及精确数字运算,Date类)

    一 java获取当前时间 学习一个函数,得到当前时间的准确值 System.currectTimeMillis(). 可以得到以毫秒为单位的当前时间.它主要用于计算程序运行时间,long start= ...

  9. js获取当前时间显示在页面上

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  10. Android获取系统时间方法的总结

    Android获取系统时间方法的方法有很多种,常用的有Calendar.Date.currentTimeMills等方法. (1)Calendar Calendar获取系统时间首先要用Calendar ...

随机推荐

  1. org.apache.http.NoHttpResponseException: XX.XX.XX.XX:80 failed to respond

    解决: Finally I fix the issue and it is caused by buffer size. By default, buffer size of httpclient i ...

  2. MySQL随机取数据

    // 随机取9个 $rand_sql = "SELECT * FROM `tf_product` WHERE (`id` >= ((SELECT MAX(`id`) FROM `tf_ ...

  3. pdf2swf+flexpaper解决pdf在线阅读(类百度文库)

    1:工具准备swftools.exe 下载 http://www.swftools.org/download.html 安装至D盘 SWFTools提供了一系列将各种文件转成swf的工具: font2 ...

  4. c++中对齐方式

    使用cout<<setiosflags(ios::right)以后, 再调用 cout<<setiosflags(ios::left);无效的, 你可以在调用之前加上一句 co ...

  5. 【微信小程序+ES6新特性应用】字符串模板:美元符号$+大括号{}变量的写法

    1.字符串模板简介 ES6新特性中的字符串模板允许使用英文字符抑音符号`(提示:这里我们不能将其理解为单引号)来创建字符串,并且在该字符串中可以包含都[美元符号+大括号]包裹的变量 格式:consol ...

  6. Spring_总结_01_Spring概述

    一.前言 从今天开始,重新总结一下Spring的相关知识,主要是结合<Spring实战(第四版)>和 <JavaEE开发的颠覆者——SpringBoot实战>这两本书以及官方文 ...

  7. Tomcat_总结_01_tomcat环境搭建

    一.准备条件 1.安装jdk 二.安装tomcat 1.下载tomcat 去官网下载  64-bit Windows zip  版本的tomcat,并解压 https://tomcat.apache. ...

  8. CSS 文本实例

    1.设置文本的颜色 color:red; color:#00ff00 color:rgb(0,0,255) 2.增加或减少字符间距 letter-spacing:-0.5em letter-spaci ...

  9. stl_algo.h

    stl_algo.h // Filename: <stl_algo.h> // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: ...

  10. UVA 11605 Lights inside a 3d Grid

    #include <iostream> #include <stdio.h> #include <cstring> #include <math.h> ...