C++で今日の日付をyyyymmddで取得

#include <ctime>

...

  std::time_t rawtime;
  std::tm timeinfo;
  
  std::time(&rawtime);
  localtime_s(&timeinfo,&rawtime);
  long tmpYYYYMMDD = (1900+timeinfo.tm_year) * 10000 + (timeinfo.tm_mon+1) * 100 + timeinfo.tm_mday;

ネタ元