1 頁 (共 1 頁)

如何取得標準時間字串

發表於 : 2008年 11月 27日, 16:43
tim
請參考,
http://msdn.microsoft.com/library/defau ... gmtime.asp

代碼: 選擇全部

     
    /* GMTIME.C: This program uses gmtime to convert a long- 
     * integer representation of coordinated universal time 
     * to a structure named newtime, then uses asctime to 
     * convert this structure to an output string. 
     */ 
     
    #include <time.h> 
    #include <stdio.h> 
     
    void main( void ) 
    { 
       struct tm *newtime; 
       long ltime; 
     
       time( &ltime ); 
     
       /* Obtain coordinated universal time: */ 
       newtime = gmtime( &ltime ); 
       printf( "Coordinated universal time is %sn",  
                                   asctime( newtime ) ); 
    }