std::get_time

Header: <iomanip>

When used in an expression in » get_time(tmb, fmt), parses the character input as a date/time value according to format string fmt according to the std::time_get facet of the locale currently imbued in the input stream in. The resultant value is stored in a std::tm object pointed to by tmb.

# Declarations

template< class CharT >
/*unspecified*/ get_time( std::tm* tmb, const CharT* fmt );

(since C++11)

# Parameters

# Return value

An object of unspecified type such that

# Notes

As specified in std::time_get::do_get, which this function calls, it’s unspecified if this function zero out the fields in *tmb that are not set directly by the conversion specifiers that appear in fmt: portable programs should initialize every field of *tmb to zero before calling std::get_time.

# Example

#include <iomanip>
#include <iostream>
#include <locale>
#include <sstream>
 
int main()
{
    std::tm t = {};
    std::istringstream ss("2011-Februar-18 23:12:34");
    ss.imbue(std::locale("de_DE.utf-8"));
    ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S");
 
    if (ss.fail())
        std::cout << "Parse failed\n";
    else
        std::cout << std::put_time(&t, "%c") << '\n';
}

# See also