Я пытаюсь превратить произвольные целочисленные значения, представляющие секунды с 1 января 1970 года, в удобочитаемые даты.
Это так близко, как я получил, но я продолжаю получать текущую дату. Как я могу получить struct tm
даты, которая не является текущей датой?
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
int main() {
struct tm * timeStruct;
time_t myTime = 946684800; //s from 1970 to 2000
int timeStamp = time(&myTime); //I thought this would set the date to the values of myTime, it just sets it to now
timeStruct = localtime(&myTime);
cout << timeStamp;
cout << "\n";
cout << asctime(timeStruct); //This should read Jan 1, 2000, instead it keeps giving me the current time
cout << "\n";
system("pause");
return 0;
}