Got Lösung ...
1) Convert String formatiert Zeit, um Time_t
2) verwenden "localtime_s" utc um Ortszeit zu konvertieren.
3) verwenden "strftime" Ortszeit (struct tm-Format) auf String-Format zu konvertieren.
int main()
{
std::string strUTCTime = "2017-03-17T13:20:00Z";
std::wstring wstrUTCTime = std::wstring(strUTCTime.begin(),strUTCTime.end());
time_t utctime = getEpochTime(wstrUTCTime.c_str());
struct tm tm;
/*Convert UTC TIME To Local TIme*/
localtime_s(&tm, &utctime);
char CharLocalTimeofUTCTime[30];
strftime(CharLocalTimeofUTCTime, 30, "%Y-%m-%dT%H:%M:%SZ", &tm);
string strLocalTimeofUTCTime(CharLocalTimeofUTCTime);
std::cout << "\n\nLocal To UTC Time Conversion:::" << strLocalTimeofUTCTime;
}
std::time_t getEpochTime(const std::wstring& dateTime)
{
/* Standard UTC Format*/
static const std::wstring dateTimeFormat{ L"%Y-%m-%dT%H:%M:%SZ" };
std::wistringstream ss{ dateTime };
std::tm dt;
ss >> std::get_time(&dt, dateTimeFormat.c_str());
/* Convert the tm structure to time_t value and return Epoch. */
return _mkgmtime(&dt);
}
Was haben Sie versucht? – UnholySheep
Versuch localtime_s..working auf, es zu benutzen .. –
ausprobieren Überprüfung http://stackoverflow.com/questions/21021388/how-to-parse-a-date-string-into-a-c11-stdchrono-time- Punkt-oder-ähnliche – Edd