C++ time timestamp convert

//input demo:2001-01-18 09:41:50
std::time_t TimeStringToTimestamp(std::string datetime) {
	std::tm t{};
	std::istringstream ss(datetime);

	ss >> std::get_time(&t, "%Y-%m-%d %H:%M:%S");
	if (ss.fail()) {
		throw std::runtime_error{ "failed to parse time string" };
	}
	std::time_t time_stamp = mktime(&t);
	return time_stamp;
}
//input demo:1401920000
std::string TimestampToTimeString(const std::time_t timestamp) {
	struct tm* dt;
	char buffer[30];
	dt = localtime(×tamp);
	strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", dt);
	return std::string(buffer);
}