time_t转换成时间字符串


#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>
using namespace std;
int main()
{
    time_t t;  //秒时间  
    tm local; //本地时间   
    tm* gmt;   //格林威治时间  
    char buf[128] = { 0 };
    t = time(NULL); //获取目前秒时间  
    localtime_s(&local,&t); //转为本地时间  
    strftime(buf, 64, "%Y-%m-%d %H:%M:%S", &local);
    std::cout << buf << std::endl;
return 0;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM