Click here to Skip to main content
15,893,994 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello I just tried to get a value which equals to the one which is generated in php by calling time().

This one was generated by php: 1353963208650

And this one by c++ : 1353963158

They equal but somehow the c++ value is just 4 bytes. The last 4 bytes are nulled,but I need a value which equals 100%. My Code atm:

C++
time_t seconds = time(NULL);
printf("PHP-Time: %ld\n",seconds);
Posted
Comments
Sergey Alexandrovich Kryukov 26-Nov-12 16:31pm    
What is exactly "+C++ time" and how did you obtain it? For example ctime (time.h) tm is one thing, but it's a structure of 9 integers (!). Windows time is 64-bit number (in 100-ns units), and so on... I have no idea what is the 4-byte (just 32-bit) value you mention -- IMHO, not enough to represent time with sufficient accuracy and range... :-)
--SA

1 solution

How did you get your results?
My test:
(output)

1353965820 (C++)
1353965860 (PHP)

(of course they differ a bit, because were executed at different times)

(programs)
C++
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
  cout << time(NULL) << endl;
  return 0;
}

PHP
<?php 
echo time();
 ?>
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Nov-12 18:04pm    
Right. Same question I asked. My 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900