Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2964

Re: mktime 2-digit vs 4-digit year

From "A" <a@a.a>
Newsgroups comp.lang.php
Subject Re: mktime 2-digit vs 4-digit year
Date 2011-08-27 01:14 +0200
Organization B.net Hrvatska d.o.o.
Message-ID <j399e9$5sq$1@gregory.bnet.hr> (permalink)
References <d3511025-608d-4369-9ba8-23875c9b555d@h9g2000vbr.googlegroups.com>

Show all headers | View raw


> 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. 

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web