//方案一,将当前时间折算为秒级,再通过相应的时间换算即可
//此文件必须是c++文件
/*
#include<iostream>
#include<ctime>
using namespace std;
string now() {
time_t t = time(0);
char buffer[9] = {0};
strftime(buffer, 9, "%H:%M:%S", localtime(&t));
return string(buffer);
}
int main()
{
cout<<now()<<endl;
return 0;
}
*/
方法二:boost库中的:
#include <stdio.h> // for sprintf()
#include <iostream> // for console output
#include <string> // for std::string
#include <boost/date_time/posix_time/posix_time.hpp>
//-----------------------------------------------------------------------------
// Format current time (calculated as an offset in current day) in this
//此文件必须是c++文件
/*
#include<iostream>
#include<ctime>
using namespace std;
string now() {
time_t t = time(0);
char buffer[9] = {0};
strftime(buffer, 9, "%H:%M:%S", localtime(&t));
return string(buffer);
}
int main()
{
cout<<now()<<endl;
return 0;
}
*/
方法二:boost库中的:
#include <stdio.h> // for sprintf()
#include <iostream> // for console output
#include <string> // for std::string
#include <boost/date_time/posix_time/posix_time.hpp>
//-----------------------------------------------------------------------------
// Format current time (calculated as an offset in current day) in this