Click here to Skip to main content
11,921,354 members (57,282 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++
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 11: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
0 OriginalGriff 543
1 Dave Kreskowiak 245
2 phil.o 160
3 KrunalRohit 134
4 Sergey Alexandrovich Kryukov 132
0 OriginalGriff 6,951
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,171
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web02 | 2.8.151120.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2015
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