C获取当前时间
#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(¤tTime);
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获取当前时间的更多相关文章
- iOS中获取当前时间,设定时间,并算出差值
NSDate *date = [NSDate date];//获取当前时间 NSTimeZone *zone = [NSTimeZone systemTimeZone];//修改时区 NSIntege ...
- Js获取当前日期时间及其它操作
Js获取当前日期时间及其它操作var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份 ...
- 【转】Js获取当前日期时间及格式化操作
(转自:http://www.cnblogs.com/qinpengming/archive/2012/12/03/2800002.html) var myDate = new Date(); myD ...
- PHP 获取中国时间,即上海时区时间
/** * 获取中国时间,即上海时区时间 * @param <type> $format * @return <type> */ function getChinaTime($ ...
- C#获取北京时间与设置系统时间
获取北京时间 public static DateTime GetBeijingTime() { DateTime dt; // 返回国际标准时间 // 只使用 timeServers 的 IP 地址 ...
- jquery 获取日期时间
获取JavaScript 的时间使用内置的Date函数完成 var mydate = new Date();mydate.getYear(); //获取当前年份(2位)mydate.getFullYe ...
- 使用 jquery 获取当前时间的方法
我们在写一些效果时,经常要用到 jquery 获取当前时间,但是jquery 目前并没有提供直接获取当前时间的 api 或者函数,所以我们还是得用原生的 javascript 时间对象 Date 来获 ...
- java学习第13天( java获取当前时间,有关大数据的运算及精确数字运算,Date类)
一 java获取当前时间 学习一个函数,得到当前时间的准确值 System.currectTimeMillis(). 可以得到以毫秒为单位的当前时间.它主要用于计算程序运行时间,long start= ...
- js获取当前时间显示在页面上
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- Android获取系统时间方法的总结
Android获取系统时间方法的方法有很多种,常用的有Calendar.Date.currentTimeMills等方法. (1)Calendar Calendar获取系统时间首先要用Calendar ...
随机推荐
- jq中同个页面点击事件和回车事件
button元素,绑定一系列事件的时候,点击-回车-回车,会出现错误. 解决办法,就是把button变成a 详情是,一个页面中有点击按钮,按钮点击之后,出现弹框1,点击弹框1的确定,出现弹框2,点击弹 ...
- Java中各种集合特点总结
1:集合: (1) Collection(单列集合) List(有序,可重复) ArrayList 底层数据结构是数组,查 ...
- Spring Boot入门——JDBCTemplate使用及其相关问题解决
1.在pom.xml文件中引入相应依赖 <!-- mysql依赖 --> <dependency> <groupId>mysql</groupId> & ...
- CSS3中与文字相关的样式
1.给文字添加阴影:text-shadow属性(特别指出IE浏览器要IE10+的版本才支持) 语法如下: text-shadow:length length length color; 其中,第 ...
- spring boot: 计划任务@ EnableScheduling和@Scheduled
spring boot: 计划任务@ EnableScheduling和@Scheduled @Scheduled中的参数说明 @Scheduled(fixedRate=2000):上一次开始执行时间 ...
- 最实用的 Linux 命令行使用技巧
我们可能每天都会要使用到很多的 Linux 命令行. 我们也会网络上知晓一些使用它们的小技巧,但是如果我们没有时常来进行练习,就有可能会忘掉怎么去使用它们. 所以我就决定把那些你可能会忘记的小提示和小 ...
- NoSQL四种——kv存储(memcache,Riak),列存储(Cassandra,Hbase),文档类(mongoDB,CouchDB),图数据库(neo4j)
见:https://software.intel.com/sites/default/files/Configuration_and_Deployment_Guide_for_Cassandra_on ...
- 强大的表格控件handsometable,结合vue
handsontable handsontable是目前在前端界最接近excel的插件,可以执行编辑,复制粘贴,插入删除行列,排序等复杂操作.jQuery.react.ng和vue版本,功能强大,是复 ...
- 【.Net 】Json和Xml解析
引言 Json和Xml是现在跨平台传输数据的主流格式,关于它们的解析,网上资料很多,我稍作整理,写成一个小demo,方便日后使用. JSON解析 能进行json解析的类库有很多,例如Ja ...
- 将变参格式化到一个string对象中
该小程序演示了变参的用法.它的功能是,仿照sprintf,将变参内容保存到string中. /* 功能说明: 仿照sprintf,将字符串格式化到一个string对象中. 实现方式: 该例子主要是用来 ...