开发者

Will a x64 PHP/MYSQL build support full 64bit timestamps on a 64bit Windows Server

开发者 https://www.devze.com 2023-01-23 21:55 出处:网络
Probably a silly question, but I need to find the answer.An application we are writing needs to handle distant past and future dates, and I think handling our dates as 64bit Unix Timestamps would be a

Probably a silly question, but I need to find the answer. An application we are writing needs to handle distant past and future dates, and I think handling our dates as 64bit Unix Timestamps would be an easy solution provided I understand the PHP manual correctly, which states that the maximum int value is platform dependent and always signed. Thus a x64 platform should support 2^63 bites while a x86 platform should support 2^31 max bites.

Basically, the application only deals with integer timestamps to make our fairly complicated algorithms a little 'bit' simpler. However, trying to handle distant past or future timestamp values causes the expected overflow for any value greater than +/- 2^31 in PHP for our current x86 build. My solution is to simply compile a x64 PHP build with the free visual c++ studio download, but before I dive into that I'd like to know if my assumption is correct - "A Windows x64 PHP build will correctly handle 64bit int values, and correctly convert the Windows 'ticks' into a 64bit Unix Timestamp for its native date/time functions as it does for a x86 build."

For ex开发者_如何学编程ample:

echo mktime(0, 0, 0, 12, 31, 2055);

will return the correct timestamp, instead of false.

The same thing applies for MYSQL timestamps. For example:

SELECT UNIX_TIMESTAMP('2065-11-30 10:30:19');

will return the correct value, instead of '0' as it does for the current x86 build we have running.

-I hope I'm not too ambiguous. Thanks in advance. We're just a bunch of science geeks and not real programmers here, and are struggling with this 'trivial' issue.


Interesting question: I tried running some tests a while back, expecting a full 64-bit timestamp giving me date ranges between the big bang and the sun burning out, but found that it was still only the lower 32-bits that were being processed when passed to the date() function, even though echoing the timestamp integer value was showing the full 64-bit range.

EDIT

However, setting a dateTime object using the 64-bit range of values worked without problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消