0
点赞
收藏
分享

微信扫一扫

[C++][ubuntu]将本地时间格式化为年月日时分秒


话不多说,直接上代码

#include <time.h>
 #include<iostream>
   int main()
   {
  time_t t = time(0);
  char tmp[32] = { NULL };
  strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&t));
   std::string date(tmp);
  std::cout<<date<<std::endl;
 return 0;
   }

举报

相关推荐

0 条评论