я создания окна метка времени() функция, и я получил неправильный номер проверки на PHP микропоры функции():окна метка времени (C++)
- C++ = 1409802313
- PHP = 1410655505
В этом парование C++ writed код:
#include <windows.h>
#include <iostream> // <--- Console I/O
#include <cstdlib> // <--- Command Line
#include <sstream>
using namespace std;
void print(string value){cout << value;}
string parseStr(int value)
{
ostringstream stream;
stream<<value<<flush;
return stream.str();
}
// ============================================================
// TIMESTAMP
// ============================================================
string timestamp()
{
SYSTEMTIME system_time;
GetLocalTime(&system_time);
int year = system_time.wYear;
int month = system_time.wMonth;
int day = system_time.wDay;
int hour = system_time.wHour;
int minute = system_time.wMinute;
int second = system_time.wSecond;
int milliseconds = system_time.wMilliseconds;
int day_of_year = 0;
if (month > 1){day_of_year += 31;} // Sausis
if (month > 2){day_of_year += 28;} // Vasaris
if (month > 3){day_of_year += 31;} // Kovas
if (month > 4){day_of_year += 30;} // Balandis
if (month > 5){day_of_year += 31;} // Geguze
if (month > 6){day_of_year += 30;} // Birzelis
if (month > 7){day_of_year += 31;} // Liepa
if (month > 8){day_of_year += 31;} // Rugpjutis
if (month > 9){day_of_year += 30;} // Rugsejis
if (month > 10){day_of_year += 31;} // Spalis
if (month > 11){day_of_year += 30;} // Lapkritis
if (month > 12){day_of_year += 31;} // Gruodis
day_of_year += day;
int time = 0;
time += (year - 1970) * 31536000;
time += day_of_year * 86400;
time += hour * 3600;
time += minute * 60;
time += second;
string time_string;
time_string = parseStr(time);
return time_string;
}
// ============================================================
int main()
{
while(true)
{
system("cls");
string time = timestamp();
print(time);
Sleep(100);
}
return 0;
}
Я вычисляю что-то неправильно или что-то неправильно с целыми типами? :(
'month_of_year> 12'? Когда может быть месяц больше 12? – Barmar
Вместо скриншотов, которые трудно читать, вы могли бы просто опубликовать отметки времени, которые вы получаете от своего кода и PHP? – Barmar
(month_of_year> 12) - это просто комментарий, чтобы не забывать позже. :) – Aliarth