I'm trying to get the time in a different timezone (PST) using C++.

#define PST (-8);
char* Time::getSecondSystemTime() {
    time_t rawtime;
    struct tm * timeinfo;
    char buffer[80];

    time(&amp;rawtime);
    timeinfo = gmtime(&amp;rawtime);

    timeinfo-&gt;tm_hour = timeinfo-&gt;tm_hour + PST;

    strftime(buffer, 80, "%I:%M %p", timeinfo);


    std::string temp = std::string(buffer); // to get rid of extra stuff
    std::string extraInfo = " Pacific Time ( US &amp; Canada )";

    temp.append(extraInfo);

    return (char*) (temp.c_str());

}


The problem here is that when the GMT time is less than 8 hours (for example, right now, the time there is 3AM in the morning), subtracting 8 hours from it does not work!

What is the proper way to get time at a different time zone in Unix?


Question: How do I find the most populous cities in the world?
Answer: Leave out Length in Length[CityData[#, "Population"]], and delete cases of Missing data:

numberofpeople = Map[{#, CityData[#, "Population"]} &amp;, CityData[All]];

Reverse[SortBy[DeleteCases[numberofpeople, {_, _Missing}], Last]] ~Take~ 20 // Grid