最終更新日時:
が更新

履歴 編集

function
<cwchar>

std::wcsftime

namespace std {
  size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const tm* timeptr);
}

概要

日時を書式化して、ワイド文字列へ出力する。

戻り値

書き込んだ文字数(終端のヌル文字を含まない)を返す。結果がmaxsize文字に収まらなかった場合は0を返し、sの内容は不定である。

備考

#include <cwchar>
#include <ctime>
#include <iostream>

int main()
{
  std::tm tm{};
  tm.tm_year = 126; // 2026年
  tm.tm_mon = 8;    // 9月
  tm.tm_mday = 8;

  wchar_t buffer[32];
  std::wcsftime(buffer, 32, L"%Y-%m-%d", &tm);

  std::wcout << buffer << std::endl;
}

出力

2026-09-08

バージョン

言語

  • C++98

関連項目