# std::chrono::operator<< (std::chrono::year_month)

From cppreference.com
< cpp‎ | chrono‎ | year month

template< class CharT, class Traits > std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const std::chrono::year_month& ym); |  | (since C++20)

Outputs a textual representation of `ym` into the stream `os`, as if by os << ym.year() << '/' << ym.month().

### Return value

`os`.

### Notes

This `operator<<` is primarily intended for debugging use. When used with non-default stream flags, the output may be surprising:

    using namespace std::chrono;
    auto ym = 2001y/February;
    std::cout.width(10);
    std::cout.fill('-');
    std::cout << std::left << ym; // may output "2001------/Feb"

For control over formatting, use std::chrono::format.

### See also

to_stream | outputs a `year_month` into a stream according to the provided format (function template)
format (C++20) | formats a streamable `chrono` object for insertion (function template)

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/year_month/operator_ltlt&oldid=104850"