zoukankan      html  css  js  c++  java
  • wxDateTime用法和转换成wxString

    转载别人的。
    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<<" wxDateTime::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(0,1); wxDateTime then=now.Add(span); cout<<then.Format(wxT("%B %d %Y"))<<endl; }

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

    1     wxDateTime now=wxDateTime::Now();
    2     wxString date = now.Format(wxT("%Y-%m-%d"),wxDateTime::A_EST);
    3 
    4 wxdatetime和wxstring互换
    5 wxstring to wxdatetime:   
    6 char* ca = "2008-09-03";
    7 wxDateTime dt;dt.ParseDate(ca);
  • 相关阅读:
    剑指offer字符串列表
    剑指offer数组3
    剑指offer数组2
    剑指offer数组1
    剑指offer数组列表
    tensorflow+ssd_mobilenet实现目标检测的训练
    Win7+keras+tensorflow使用YOLO-v3训练自己的数据集
    Java是如何实现跨平台的
    Xshell 、PuTTY 复制文件到Linux
    Asp.Net Core2.0在linux下发布
  • 原文地址:https://www.cnblogs.com/starf/p/3656407.html
Copyright © 2011-2022 走看看