Home »
Imported messages »
comp.lang.php »
mktime 2-digit vs 4-digit year
Re: mktime 2-digit vs 4-digit year [message #175223 is a reply to message #175218] |
Sat, 27 August 2011 14:54 |
BKDotCom
Messages: 7 Registered: October 2010
Karma:
|
Junior Member |
|
|
On Aug 26, 6:14 pm, "A" <a...@a.a> wrote:
>> the mktime() year argument expects an integer
>> how does it know if I passed a 2-digit vs 4 digit value?
>> testing 0 <= year < 100 simply isn't good enough... what If I want to
>> specify years 0000 - 0099 (which should be possible on a 64-bit
>> system)
>
> mktime was not designed to do that. 0-99 are interpreted as 2 digits. mktime
> accepts 2 or 4 digit year. valid range is from 1901 and 2038 on 32-bit
> system so you can't even interpret anything outside of that range. it is
> Year 2038 problem -http://en.wikipedia.org/wiki/Year_2038_problem
>
> for anything outside of that range you probably need to make your own
> library.
That's just it, I don't know how it would be possible to code in
straight PHP
unless it accepted a string for the year" "0000" - "0099" and use
strlen()
I've created a datetime_mktime() func that uses the DateTime class and
DateTime::add / DateTime::sub to create the date thus avoiding the 32-
bit limitation on 32-bit systems.
It takes the same args as mktime() it'd be nice if it were able to
accept 00-99 and know that's referring to 1970-2069 and also accept
0000-0099
|
|
|
Goto Forum:
Current Time: Thu Nov 28 14:44:11 GMT 2024
Total time taken to generate the page: 0.03111 seconds