From: Ehsanul Hoque Date: 2009-09-25T14:38:20+09:00 Subject: Re: Parsing dates --_c8ad2b35-74cf-4fd0-8ff8-dee92537b468_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable > When I do this: >=20 > dob=3D"05/01/1968" > x=3DDate.parse(dob) > x.month >=20 > I get 1 instead of 5. > How do I do this? >=20 Well=2C it's not a bug or something. The rest of the world uses day/month/y= ear so that is the default that the Date.parse method uses. The easiest solution (and the best way to do this IMO) is to just feed the = method "01/05/1968" instead of "05/01/1968". If for some reason=2C you HAVE to have the m/d/y format=2C you could just u= se a regexp. Could be something like this=2C but note=2C it's not really th= e best regexp=2C just something I came up with now (you can use rubular.com= to figure out ruby regexps easily): dob =3D "05/01/1968" dob =3D~([01]\d)\/([0-3]\d)\/((19|20)\d\d) =0A= _________________________________________________________________=0A= Bing=99 brings you maps=2C menus=2C and reviews organized in one place. = Try it now.=0A= http://www.bing.com/search?q=3Drestaurants&form=3DMLOGEN&publ=3DWLHMTAG&cre= a=3DTEXT_MLOGEN_Core_tagline_local_1x1= --_c8ad2b35-74cf-4fd0-8ff8-dee92537b468_--