cocos2dx 3.1获取系统当前时间
std::string Tools::getcurrTime()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
struct timeval now;
struct tm* time;
gettimeofday(&now, NULL);
time = localtime(&now.tv_sec);
;
log("year = %d",year);
] = {};
sprintf(date, ,(,(int)time->tm_mday);
log("%s",date);
return StringUtils::format("%s",date);
#endif
#if ( CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 )
struct tm* tm;
time_t timep;
time(timep);
tm = localtime(&timep);
] = {};
sprintf(date, ,(,(int)time->tm_mday);
log("%s",date);
return StringUtils::format("%s",date);
#endif
}
以上是获取当前年月日
---------------------------------详解的其他方法
linux,ios下的
struct cc_timeval now; CCTime::gettimeofdayCocos2d(&now, NULL); struct tm *tm; tm = localtime(&now.tv_sec); ; ; int day = tm->tm_mday; int hour=tm->tm_hour; int minute=tm->tm_min; int second=tm->tm_sec; + now.tv_usec / ;
win32下
struct tm *tm; time_t timep; time(&timep); tm = localtime(&timep); ; ; int day = tm->tm_mday; int hour=tm->tm_hour; int minute=tm->tm_min; int second=tm->tm_sec;
cocos2dx 3.1获取系统当前时间的更多相关文章
- java获取系统指定时间年月日
java获取系统指定时间年月日 private String setDateTime(String falg) { Calendar c = Calendar.getInstance(); c.set ...
- Unity3D获取系统当前时间,并格式化显示
Unity 获取系统当前时间,并格式化显示.通过“System.DateTime”获取系统当前的时间,然后通过格式化把获得的时间格式化显示出来,具体如下: 1.打开Unity,新建一个空工程,Unit ...
- Oracle,MySQL,sqlserver三大数据库如何获取系统当前时间
Oracle中如何获取系统当前时间:用SYSDATE() MySQL中获取系统当前时间主要有以下几点: (1)now()函数以('YYYY-MM-dd HH:mm:SS')返回当前的日期时间,可以直接 ...
- java 获取系统当前时间并格式化
java 获取系统当前时间并格式化 CreateTime--2018年5月9日11:41:00 Author:Marydon 实现方式有三种 updateTime--2018年7月23日09点32 ...
- 使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期
1.使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期: 1 var newdate = new Date(); 2 var nowyear = newdat ...
- C++ 获取系统当前时间(日历时)
获取系统当前时间(日历时) //Linux & C++11 #include <chrono> #include <ctime> using namespace std ...
- android service 样例(电话录音和获取系统当前时间)
关于android service 的具体解释请參考: android四大组件--android service具体解释.以下将用两个实例具体呈现Android Service的两种实现. 一个是st ...
- C# 获取系统开机时间
原文:C# 获取系统开机时间 /// /// 获取系统开机时间 /// /// private DateTime GetComput ...
- C/C++获取系统当前时间
C/C++获取系统当前时间 C库中与系统时间相关的函数定义在<time.h>头文件中, C++定义在<ctime>头文件中. 一.time(time_t*)函数 函数定义如 ...
随机推荐
- A ship is always safe at the shore - but that is not what it is built for.
A ship is always safe at the shore - but that is not what it is built for. 船靠岸边总是安全的,但那不是建造它的目的.
- sys,os,模块-正则表达式
# *__conding:utf-8__* """"我是注释""" sys,os模块 import sysimport os pr ...
- MFC编辑框字体大小调节(转)
在学习MFC中需要调整编辑框中的字体大小,以下是我结合网上与自己实际操作总结的,希望对其它同学有所帮助. 首先,了解以下函数原型:BOOL CreateFont( int nHeight, ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C
Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...
- What's the difference between <b> and <strong>, <i> and <em> in HTML/XHTML? When should you use each?
ref:http://stackoverflow.com/questions/271743/whats-the-difference-between-b-and-strong-i-and-em The ...
- winform 移动窗体,和窗体阴影(引用)
无边框窗体移动://窗体移动API [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [D ...
- java正则表达式【大全】
[正则表达式]文本框输入内容控制整数或者小数:^[0-9]+\.{0,1}[0-9]{0,2}$只能输入数字:"^[0-9]*$".只能输入n位的数字:"^\d{n}$& ...
- 我为开源做贡献,网页正文提取——Html2Article
为什么要做正文提取 一般做舆情分析,都会涉及到网页正文内容提取.对于分析而言,有价值的信息是正文部分,大多数情况下,为了便于分析,需要将网页中和正文不相干的部分给剔除.可以说正文提取的好坏,直接影响了 ...
- JavaScript继承
最佳的继承范式 寄生组合继承 我们来看一下它的实现方式: function Object(o){ var TempObject = function(){}; TempObject.prototype ...
- 省市级联.net
初学javascript,编译省市级联,使用json在一般处理程序中编译,利用ajax传递数据到web前台 <html xmlns="http://www.w3.org/1999/xh ...