Why, when I try to get todays date, do I get yesterday's date?

I saw some warning in my compiler (Visual studio 2012) that localtime is unsafe but I don't think I should use localtime_s because it's non-standard c++ from what I understand and I need to write code that complies with the 98' (I think) standard for my class.

Today is 3/3/2014 but this gives me 3/2/2014

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <ctime>
#include <sstream>
using namespace std;

int main()
{
	stringstream dateStringStream;
	string date;

	time_t rawTime;
	struct tm* timeinfo;

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

	
	dateStringStream << timeinfo->tm_mday << "/"
	<< timeinfo->tm_mon << "/"
	<< (timeinfo->tm_year + 1900);

	 dateStringStream >> date;

	 cout << date;
	
	cin.get();
	return 0;
}
http://en.cppreference.com/w/cpp/chrono/c/tm
int tm_mon months since January – [0, 11]

Everything is correct:
January: 0
February: 1
March: 2

Add one if you want human-like numeration.
Ahhhh. Ok thanks.
Topic archived. No new replies allowed.