- time_t t; //秒时间
- tm* local; //本地时间
- tm* gmt; //格林威治时间
- char buf[128]= {0};
- t = time(NULL); //获取目前秒时间
- local = localtime(&t); //转为本地时间
- strftime(buf, 64, "%Y-%m-%d %H:%M:%S", local);
- std::cout << buf << std::endl;
- gmt = gmtime(&t);//转为格林威治时间
- strftime(buf, 64, "%Y-%m-%d %H:%M:%S", gmt);
- std::cout << buf << std::endl;
时间函数---转换成指定格式的时间函数
最新推荐文章于 2022-12-21 16:41:48 发布