Question : Simple String to UTC format

Hi,

I have a string HHMM. I need to convert it to full UTC date format in C++.

Example:
Lets say today's date is, Jul 13th, 2010
I have a string with value: 1438 (2:38pm EST)
I need to output in GMT as Jul 13 2010 19:38:00 000 PM

How can I do this? I am not familiar with Boost, but I can use Boost libs.
Any help is appreciated.

Thanks,

Answer : Simple String to UTC format

Oops. Forgot a small part. Make that :
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
#include <ctime>

std::string myTime = "1438";

time_t now = time(0);
struct tm* now_tm = localtime(&now);

now_tm->tm_hour = atoi(myTime.substr(0, 2).c_str());
now_tm->tm_min = atoi(myTime.substr(2, 2).c_str());
now_tm->tm_sec = 0;

time_t target = mktime(now_tm);

char timestamp[32] = "";
strftime(timestamp, 32, "%b %d %Y %I:%M:%S 000 %p", gmtime(&target));

std::cout << timestamp << std::endl;
Random Solutions  
 
programming4us programming4us