Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2962 > unrolled thread
| Started by | BKDotCom <kent.brad@gmail.com> |
|---|---|
| First post | 2011-08-26 12:56 -0700 |
| Last post | 2011-08-28 17:15 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.lang.php
mktime 2-digit vs 4-digit year BKDotCom <kent.brad@gmail.com> - 2011-08-26 12:56 -0700
Re: mktime 2-digit vs 4-digit year "A" <a@a.a> - 2011-08-27 01:14 +0200
Re: mktime 2-digit vs 4-digit year BKDotCom <kent.brad@gmail.com> - 2011-08-27 07:54 -0700
Re: mktime 2-digit vs 4-digit year BKDotCom <kent.brad@gmail.com> - 2011-08-27 11:05 -0700
Re: mktime 2-digit vs 4-digit year "A" <a@a.a> - 2011-08-28 17:15 +0200
| From | BKDotCom <kent.brad@gmail.com> |
|---|---|
| Date | 2011-08-26 12:56 -0700 |
| Subject | mktime 2-digit vs 4-digit year |
| Message-ID | <d3511025-608d-4369-9ba8-23875c9b555d@h9g2000vbr.googlegroups.com> |
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) What keeps them from being being interpreted as 1970-2069? Or do they? (I don't have a 64-bit system to test on) And if it does correctly accept the year 0000 - 0099, how could my own code distinguish between 0000 and 00 ?
[toc] | [next] | [standalone]
| From | "A" <a@a.a> |
|---|---|
| Date | 2011-08-27 01:14 +0200 |
| Message-ID | <j399e9$5sq$1@gregory.bnet.hr> |
| In reply to | #2962 |
> 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. > And if it does correctly accept the year 0000 - 0099, how could my own > code distinguish between 0000 and 00 ? You can't. 0000 == 00. so 00 - 99 is simply an alias for 1900-1999.
[toc] | [prev] | [next] | [standalone]
| From | BKDotCom <kent.brad@gmail.com> |
|---|---|
| Date | 2011-08-27 07:54 -0700 |
| Message-ID | <b314741f-e8cb-4d8c-92fc-1706b70d5ab9@x14g2000prn.googlegroups.com> |
| In reply to | #2964 |
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
[toc] | [prev] | [next] | [standalone]
| From | BKDotCom <kent.brad@gmail.com> |
|---|---|
| Date | 2011-08-27 11:05 -0700 |
| Message-ID | <dd473ba9-84c7-44fc-ada8-f59babadcd45@s35g2000prm.googlegroups.com> |
| In reply to | #2970 |
Executive decision on my part. If you pass 85 to my function it will be interpreted literally as year 85 (not 1985) however, It'll also accept strings for the year. "85" will be interpreted as 1985. In case someone needs that 2-digit functionality. What bonehead is using 2-digit years?! :)
[toc] | [prev] | [next] | [standalone]
| From | "A" <a@a.a> |
|---|---|
| Date | 2011-08-28 17:15 +0200 |
| Message-ID | <j3dm57$2jp$1@gregory.bnet.hr> |
| In reply to | #2972 |
mktime is more like a port of 32bit c++ version of mktime which functions has the same valid range. but in c++ there is also mktime64 for ages which i haven't seen in php. so there is nothing bonehead... it's just how it is made to work. accept it or find some alternative how to do it.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web