Click here to Skip to main content
13,090,299 members (90,295 online)
Rate this:
Please Sign up or sign in to 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:

time_t seconds = time(NULL);
printf("PHP-Time: %ld\n",seconds);
Posted 26-Nov-12 10:07am
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... :-)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

How did you get your results?
My test:

1353965820 (C++)
1353965860 (PHP)

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

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

echo time();
Sergey Alexandrovich Kryukov 26-Nov-12 18:04pm
Right. Same question I asked. My 5.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100