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