Today date output as word

Hello everyone!

I would like my output of the day be like this:

Example today date is: Tuesday 12:00

MY current program output's 29 12:00

1
2
3
4
5
6
7
8
9
10
11
  time_t rawtime;
  struct tm * timeinfo;
  char buffer[80];

  time (&rawtime);
  timeinfo = localtime(&rawtime);

  strftime(buffer,80,"%d %I:%M",timeinfo);
  std::string str(buffer);

  std::cout << str;
With strftime(), %d gives the day of the month. You want %A for the day of the week.
http://www.cplusplus.com/reference/ctime/strftime/
Manipulator std::put_time http://en.cppreference.com/w/cpp/io/manip/put_time

1
2
3
4
5
6
7
8
9
#include <iostream>
#include <ctime>
#include <iomanip>

int main()
{
    const auto raw_time = std::time(nullptr) ;
    std::cout << std::put_time( std::localtime( &raw_time ), "%A %I:%M %p (%Z)\n" ) ;
}

http://coliru.stacked-crooked.com/a/a913571c1ca81ec6
http://rextester.com/GTLF12057
Topic archived. No new replies allowed.