2

I'm working on my own calendar application, and I'm currently facing the problem that, as soon as I enter a time later than ca. 2040 the number (seconds) gets too big and can't be saved in a variable of the type "int" anymore.

It seems to be clear that I have to cast my variable (that's what google said), but somehow it doesn't work ...

I don't know whether the php functions won't accept any other variable types than int or if I just didn't figure it out right, but I'm sure I'm not the only nor the first one facing this problem.

So do you have any suggestions how to cope with this problem?

Radix
  • 667
  • 5
  • 28
Marco7757
  • 735
  • 9
  • 16

1 Answers1

0

There is a lot of information here: http://php.net/manual/en/language.types.integer.php

Try using a 64-bit environment.

Thom Mahoney
  • 481
  • 1
  • 3
  • 12
  • Are you suggesting that the OP buy a new computer to write his function? – Gabe Jan 09 '12 at 21:22
  • 1
    I use strtotime() to create a timestamp. Obviously the number that is created breakes the bounds of the integer type. On the page you posted (I already read it), it says: "If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead." So why isn't the number interpreted as a float by php automatically? Why do casts not change anything? – Marco7757 Jan 09 '12 at 22:49
  • @Gabe it must be a computer of the last century production the op is using. Otherwise it supports 64-bit operations as well. *Operation system* may be you mean – Your Common Sense Jan 09 '12 at 22:57
  • php.net says that _strtotime()_ returns false if something goes wrong. Could it be that false is interpreted as 0, which is why I get 1st of January 1970? – Marco7757 Jan 12 '12 at 19:04