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获取系统当前时间的更多相关文章

  1. java获取系统指定时间年月日

    java获取系统指定时间年月日 private String setDateTime(String falg) { Calendar c = Calendar.getInstance(); c.set ...

  2. Unity3D获取系统当前时间,并格式化显示

    Unity 获取系统当前时间,并格式化显示.通过“System.DateTime”获取系统当前的时间,然后通过格式化把获得的时间格式化显示出来,具体如下: 1.打开Unity,新建一个空工程,Unit ...

  3. Oracle,MySQL,sqlserver三大数据库如何获取系统当前时间

    Oracle中如何获取系统当前时间:用SYSDATE() MySQL中获取系统当前时间主要有以下几点: (1)now()函数以('YYYY-MM-dd HH:mm:SS')返回当前的日期时间,可以直接 ...

  4. java 获取系统当前时间并格式化

      java 获取系统当前时间并格式化 CreateTime--2018年5月9日11:41:00 Author:Marydon 实现方式有三种 updateTime--2018年7月23日09点32 ...

  5. 使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期

    1.使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期: 1 var newdate = new Date(); 2 var nowyear = newdat ...

  6. C++ 获取系统当前时间(日历时)

    获取系统当前时间(日历时) //Linux & C++11 #include <chrono> #include <ctime> using namespace std ...

  7. android service 样例(电话录音和获取系统当前时间)

    关于android service 的具体解释请參考: android四大组件--android service具体解释.以下将用两个实例具体呈现Android Service的两种实现. 一个是st ...

  8. C# 获取系统开机时间

    原文:C# 获取系统开机时间 ///         ///  获取系统开机时间          ///         ///         private DateTime GetComput ...

  9. C/C++获取系统当前时间

    C/C++获取系统当前时间   C库中与系统时间相关的函数定义在<time.h>头文件中, C++定义在<ctime>头文件中. 一.time(time_t*)函数 函数定义如 ...

随机推荐

  1. 一个section刷新 一个cell刷新

    一个section刷新   一个cell刷新 //一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2]; [tabl ...

  2. Arnold AtArray API Test

    #include <ai.h> #include <iostream> #include <stdio.h> #include <vector> #in ...

  3. Nodejs基础中间件

    Nodejs基础中间件Connect   http://www.tuicool.com/articles/emeuie 关于作者 张丹(Conan), 程序员Java,R,PHP,Javascript ...

  4. 我的git与github学习历程

    因为想要知道如何把代码放到github上,所以就百度了一下,然后找到一个<如何从github上面拷贝源码>的文章,就先进行练习了下   1.首先到git官网下载git版本控制工具的安装包, ...

  5. 【Python】Python3中的str和bytes

    参考文章:Python 3的bytes/str之别 len()函数计算的是str的字符数,如果换成bytes,len()函数就计算字节数 >>> len('ABC') 3 >& ...

  6. Redhat、CentOS添加静态路由的标准方法

    我们经常遇到需要在系统默认路由的基础上,额外添加静态路由的需求.为了使得下次系统启动这些静态路由依旧生效,我们可能采取在rc.loal里加入route命令追加静态路由的方法. 现在给大家推荐Redha ...

  7. Activty四种启动模式

    Activty启动提供了四种启动模式.launchMode: standard:每次启动新的活动窗口(new操作) singleTop:如果在栈顶是目标活动,则直接打开.否则开启新的活动窗口(new) ...

  8. GitHub注册账号

    username : hcloudypassword : hujunyun3174email : 370284221@qq.com

  9. hibernate的session对象核心方法注意的问题

    1.session.save()方法 1).session.save()方法会使一个对象从临时状态转变为持久化状态. 2).session.save()方法会赋予持久化对象的OID属性一个ID值,以对 ...

  10. 修复docker pull image failed

    修复docker pull image failed docker pull报错 message":"Get https://n6-026-137.byted.org/v1/_pi ...