So, I have an assignment for my coding class and can't seem to figure out why it's outputting the wrong time! I think it has something to do with the time zones...no, i KNOW it has to do with that, but I don't know how to fix it. I've looked online and no one seems to use the code we use. If anybody could help, that'd be awesome. Also, I am trying to figure out how to insert a "0" in front of any single-digit value. For example, if the time is 12:03, I want the minutes place to display "03" and not "3" This is extra credit so I really don't mind if you don't answer that part of the question, but I would appreciate any and all help!
My current code:
#include <iostream> #include <ctime> using namespace std; int main() { int totalSeconds = time(0); int currentSecond = totalSeconds % 60; int totalMinutes = totalSeconds / 60; int currentMinute = totalMinutes % 60; int totalHours = totalMinutes / 60; int currentHour = totalHours % 12; cout << "The current time is: " << currentHour << ":"<< currentMinute << ":" << currentSecond << " GMT" << endl; system("PAUSE"); }Thanks, again!