Click here to Skip to main content
Rate this: bad
good
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
Comments
Sergey Alexandrovich Kryukov at 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

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

Solution 1

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)
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
  cout << time(NULL) << endl;
  return 0;
}
<?php 
echo time();
 ?>
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
0 /\jmot 230
1 Richard MacCutchan 185
2 Zoltán Zörgő 160
3 Richard Deeming 145
4 Sergey Alexandrovich Kryukov 145
0 Sergey Alexandrovich Kryukov 9,353
1 OriginalGriff 6,881
2 Peter Leow 4,537
3 Zoltán Zörgő 4,009
4 Richard MacCutchan 2,882


Advertise | Privacy | Mobile
Web03 | 2.8.150129.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