转载别人的。
void datetest()
{
wxDateTime now=wxDateTime::Now();
wxString date1=now.Format();
wxString date2=now.Format(wxT("%X"));
wxString date3=now.Format(wxT("%x")); //下面代码只显示日期部分
cout<<"wxDateTime now=wxDateTime::Now():"<<wxDateTime::Now().FormatDate()<<endl;
cout<<"now.Format():"<<date1<<endl;//日期时间
cout<<"now.Format(wxT(\"%X\")):"<<date2<<endl;//时间
cout<<"now.Format(wxT(\"%x\")):"<<date3<<endl;//日期 //有趣的ParseDateTime()
cout<<"\n\nwxDateTime::ParseDateTime():"<<endl; //tomorrow 是什么日子?
cout<<"tomorrow:"<<endl;
wxDateTime tomorrow;
tomorrow.ParseDateTime(wxT("tomorrow 11:00am"));
cout<<"Tomorrow is "<<tomorrow.Format()<<endl; //五一又是什么日子?
cout<<"The Labor Day test:"<<endl;
wxDateTime laborday;
laborday.ParseDate(wxT("May 1st"));
cout<<"The Labor Day is "<<laborday.Format()<<endl; //至于wxDateSpan,用法非常直白,仅举一例,顺便一提Format的另一种格式:
wxDateSpan span(,);
wxDateTime then=now.Add(span);
cout<<then.Format(wxT("%B %d %Y"))<<endl; }

另一种获取日期的办法,通过这种办法可以得到其他格式输出时间:

     wxDateTime now=wxDateTime::Now();
wxString date = now.Format(wxT("%Y-%m-%d"),wxDateTime::A_EST); wxdatetime和wxstring互换
wxstring to wxdatetime:
char* ca = "2008-09-03";
wxDateTime dt;dt.ParseDate(ca);

最新文章

  1. mono ios莫名其妙闪退的解决方法
  2. C3P0数据源的使用
  3. linux时间时区设置
  4. 《基于MVC的Javascript》
  5. String与StringBuffer对象问题
  6. 集合框架工具类--Collections排序
  7. (转)xml序列化
  8. mysqldump备份原理
  9. [妙味Ajax]第三课:AJAX跨域解决方案:JSONP
  10. 写移动端必备的meta标签
  11. IIS中遇到无法预览的问题(HTTP 错误 401.3 - Unauthorized 因为 Web server上此资源的訪问控制列表(ACL)配置或加密设置,您无权查看此文件夹或页面。)
  12. elasticsearch------java操作之QueryBuilders构建搜索Query
  13. 定时任务调度工作(学习记录 三)timer其他重要函数
  14. 解析docker中的环境变量使用和常见问题解决
  15. Hive三种安装模式
  16. C# 动态事件示例
  17. struts2+dojo实现datagrid动态刷新
  18. [javaSE] 网络编程(TCP,UDP,Socket特点)
  19. [USACO09JAN]Earthquake Damage
  20. 简述泛型、用Maven创建Web项目以及在Web项目上整合SpringMVC

热门文章

  1. 手写Mybatis,还需要后面调整下
  2. MySQL MHA之 master_ip_failover.sh脚本
  3. 循环移动List元素
  4. pandas模块之读取文件
  5. 输出匹配项:grep
  6. css----overflow(布局)
  7. 51nod 1122:机器人走方格 V4 (矩阵快速幂)
  8. 【leetcode】433. Minimum Genetic Mutation
  9. 查完数据库order_by后跟[:9]切片取前9位的值
  10. 一文带你领略虚拟化领域顶级技术会议KVM Forum 2018