Jump to content

Recommended Posts

32-bit integers have limited range. You can point to exactly 2^32 different timestamps. When you go too far into the future or the past you're fucked.

 

A signed integer, 2147483647 will be the W2K38 bug. Lets leave the problem for our children to deal with. ;)

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-995416
Share on other sites

32-bit integers have limited range. You can point to exactly 2^32 different timestamps. When you go too far into the future or the past you're fucked.

 

A signed integer, 2147483647 will be the W2K38 bug. Lets leave the problem for our children to deal with. ;)

 

Yes, but what happens when you represent the time as the number of seconds after after the Unix epoch using a signed integer and then want to represent '69? That is the problem with representing '69. Like you cannot exceed the upper bound, you also cannot go below the lower bound.

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-995497
Share on other sites

@Lamez, a longint is an int in range, is the same. As I was bored, I spent the night writing the epoch that should be!

function zeroday_time($args=false) { 
    if ($args==true){$case = $args;} else {$case = date('d/m/Y');}
    $map = array(31,28,31,30,31,30,31,31,30,31,30,31);
    $cur = explode('/', $case);
$days = $cur[0]*24*60*60;
$months = $cur[1]*($map[$cur[1]-1])*24*60*60;
$years = $cur[2]*365*24*60*60;
$result = (float)$days + $months + $years;
return (float)$result;
}

$epoch = zeroday_time(); //62129203200
$date = zeroday_time('31/12/1969'); 
$diff = abs(floor(($date-$epoch)/365/24/60/60)); //Over 40 years!?

echo "It has been $date (~{$diff}) years since December 31, 1969";

 

Surprised I got it right, calculates the offset in seconds based on January 1, 0000. Includes using doubles (+-1.79769e+308? signed, opposed to +-2147483647 in int). Screw limits, this (theoretically) will bug out when the sun explodes.

 

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-995599
Share on other sites

$today = new DateTime('today');
$timeDiff = $today->diff(new DateTime('1969-12-31'));
echo "It has been $timeDiff->y years, and $timeDiff->d days since December 31st, 1969";

 

$today = new DateTime('today');
$timeDiff = $today->diff(new DateTime('0001-1-1'));
echo "It has been $timeDiff->y years, and $timeDiff->d days since January 1st, 0001";

It has been 9 years, and 15 days since January 1st, 0001

 

I've been alive since a grand holy event!

 

Your code relies too much on the said bugs, my epoch was to overcome that.

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-995962
Share on other sites

And all along here I thought you just wanted to know how much time passed between now and December 31st, 1969.  :shy:

 

Yeah time, you can assume it's not too hard to calculate the difference, I mean it's 2010 - 40, but what I meant was to convert a timestamp to before epoch, in a fashion like the unix time stamp could not!

 

Btw, where is your massive collection of emoticons? You (and the other gurus) seem to use them alot, is it in their arsenal?  :-\

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-996029
Share on other sites

Btw, where is your massive collection of emoticons? You (and the other gurus) seem to use them alot, is it in their arsenal?  :-\

 

Oh, to have access, you need to enter a secret password in the form of a query string for that -or-, you can simply hit the [more] link found beneath the initial emoticons listed in the preview section.  ;)

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-996135
Share on other sites

Btw, where is your massive collection of emoticons? You (and the other gurus) seem to use them alot, is it in their arsenal?  :-\

 

Oh, to have access, you need to enter a secret password in the form of a query string for that -or-, you can simply hit the [more] link found beneath the initial emoticons listed in the preview section.  ;)

 

Alternatively, you can unlock them using the secret decoder ring Guru's receive in the mail.

Link to comment
https://forums.phpfreaks.com/topic/188455-very-strange/#findComment-996221
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.