http://M.TangGaowei.com

VS2005 C++ 中自己构造时间

作者 传说一梦 写于 2008-05-08  | 7,667 次浏览 | 分类 » 手机开发 |

#include <windows.h>
#include <afxwin.h>
#include <atltime.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

int _tmain(int argc, _TCHAR* argv[])
{
    char           buff[80];
    __time64_t result;

    // 构造 2008年4月28日 22:18:39 的时间
    CTime        t(2008,4,28,22,18,39);

    CString s = t.Format( _T(“%A, %B %d, %Y”) );

    struct tm when;
    t.GetLocalTm(&when);

    // 在自定义的时间上,再加 8 小时
    // 即变为 2008年4月29日 6:18:39
    when.tm_hour = when.tm_hour + 8; 

    // 重构时间,并输出显示
    if( (result = mktime( &when )) != (time_t)-1 )
    {
        asctime_s( buff, sizeof(buff), &when );
        printf( “the time will be %s\n”, buff );
    }
    else
    {
        printf( “mktime failed” );
    }
}

[ 标签: 时间处理 ]
[ 固定链接:http://m.tanggaowei.com/2008/05/08/70.html ]


Fatal error: Call to undefined function wp23_related_posts() in /home/tanggaow/public_html/m/wp-content/themes/bobv2/single.php on line 38