当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·面酵头的一生(经典)    »显示摘要«
    摘要: > > | 我是谁?我不知道,我只知道别人喊我:“面酵头”,其实我曾是一块大发面的 > > 遗留 > > > > 物,那个胖胖的手说:揪一块下来下次发面用,于是就有了我??以前寄生的时候, > > 是 > > > > | > > > > > > | 没有思想的,现在不行了......
 ·如何验证文本框输入有效性    »显示摘要«
    摘要: 用c#语言开发asp.net web应用程序(操作数据库,录入、修改、删除) 如何控制用户在输入非法字符(比如:" ^ / , ` 等)报错,并提示其 重新输入阿》 很急,望知情者,好心相告,本人必有重谢 ......


怎样获得格式化的系统当前日期

大家好,请问怎样获得格式化的系统当前日期,就是返回值是这个样子的:20030808.  
  在MFC中好像有这样的函数,  
                    //CTime   ltime;  
  //CString   ls_1;  
  //ltime=CTime::GetCurrentTime();  
  //ltime   -=   CTimeSpan(1,0,0,0);  
  //ls_1=ltime.Format("%Y%m%d");  
  //ls_1="C:\\cfdata\\"+ls_1;  
  //cout<<CTime::GetCurrentTime();  
  我想用C++的函数,但是不知道具体的格式和函数.请大家帮助.  
 

NO.1   作者: jumpcolor

void     gettime(struct   time   *timep)   本函数将计算机内的时间写入结构timep中,以供用户使用

NO.2   作者: vrace

可以这样:  
  char   szFormated[32];  
  SYSTEMTIME   st;  
  GetLocalTime(&st);  
  wsprintf("%d%02d%02d",   st.wYear,   st.wMonth,   st.wDay);  
 

NO.3   作者: vrace

修改一下最后一行,是  
  wsprintf(szFormated,   "%d%02d%02d",   st.wYear,   st.wMonth,   st.wDay);

NO.4   作者: cityvagrant

/*   LOCALTIM.C:   This   program   uses   time   to   get   the   current   time    
    *   and   then   uses   localtime   to   convert   this   time   to   a   structure    
    *   representing   the   local   time.   The   program   converts   the   result    
    *   from   a   24-hour   clock   to   a   12-hour   clock   and   determines   the    
    *   proper   extension   (AM   or   PM).  
    */  
   
  #include   <stdio.h>  
  #include   <string.h>  
  #include   <time.h>  
   
  void   main(   void   )  
  {  
                  struct   tm   *newtime;  
                  char   am_pm[]   =   "AM";  
                  time_t   long_time;  
   
                  time(   &long_time   );                                 /*   Get   time   as   long   integer.   */  
                  newtime   =   localtime(   &long_time   );   /*   Convert   to   local   time.   */  
   
                  if(   newtime->tm_hour   >   12   )                 /*   Set   up   extension.   */  
                                  strcpy(   am_pm,   "PM"   );  
                  if(   newtime->tm_hour   >   12   )                 /*   Convert   from   24-hour   */  
                                  newtime->tm_hour   -=   12;         /*       to   12-hour   clock.     */  
                  if(   newtime->tm_hour   ==   0   )                 /*Set   hour   to   12   if   midnight.   */  
                                  newtime->tm_hour   =   12;  
   
                  printf(   "%.19s   %s\n",   asctime(   newtime   ),   am_pm   );  
  }  
   
   
  Output  
   
  Tue   Mar   23   11:28:17   AM  
   
 

NO.5   作者: meimj

CString   str;  
  str.Format("%.4d%.2d%.2d",your_year,your_month,your_day);  
  好象是这样,记不清了!!

NO.6   作者: ashchan

char   szTime[10];  
  tm   time;  
  _getsystime(&time);  
  char*   format   =   "%Y%m%d";  
  strftime(szTime,   10,   format,   &time);

NO.7   作者: caomuyong1

兄弟,宏“__DATE__”和宏“__TIME__”就是分别指当前日期和时间的

NO.8   作者: kyobo

#include   <time.h>  
   
  //获取本地时间  
  void   GetlocalTime(char   *DateTime,char   *LocalDate,char   *LocalTime)  
  {  
      time_t   timer;  
      struct   tm   *tblock;  
      int   i;  
      //求当前日期及时间  
      timer   =   time(NULL);  
      tblock   =   localtime(&timer);  
      tblock->tm_mon++;  
      sprintf(DateTime,"%4d.%2d.%2d   %2d:%2d:%2d",  
        1900+tblock->tm_year,tblock->tm_mon,tblock->tm_mday,  
        tblock->tm_hour,tblock->tm_min,tblock->tm_sec);  
      for(i=0;i<(int)strlen(DateTime);i++)  
        if(DateTime[i]==   &&i!=10)  
          DateTime[i]=0;  
   
      if(LocalDate)  
        uf_strmid(LocalDate,DateTime,0,10);     //析取日期  
      if(LocalTime)  
        uf_strmid(LocalTime,DateTime,11,8);     //析取时间  
   
  }


 ·如何写这条语句    »显示摘要«
    摘要: 我想获得表中a字段为空和不为空的数量 select count(*) from table1 where a is null; select count(*) from table1 where a is not null; 如何用一条sql语句代替以上两条语句? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE