Collecting DOB info and then finding age
Posted: Sun Feb 01, 2004 7:59 pm
Hey all, here is the problem.
I'm collecting DOB information to allow me to track ages of my users (for restricting access to certain areas - its a writing site that allows uers to submit stories, some of which we would like to prevent from being pushed at young readers) but I am a bit stuck with how to go abut it.
Firstly, I want to collect the DOB in a format more like Nov 10, 1975, as the bulk of our users will be Australian (and hence use dd/mm/yy as opposed to mm/dd/yy) so I thought this format would avoid confusion.
So thats fine, I can use strtotime to convert that to a timestamp and then split that into day month and year for use in calculating their age. But of course, I find out now that the timestamp is unable to hold dates earlier than ... I think its 1970 or so.
So what I'm stuck with is the need to somehow find my own way to convert my date format to day, month, and year manually without using strtotime. But the thing that I did like was the fact that strtotime would convert succesfully even if someone used a different date format. I guess I will have to live without this.
Having said all this, I will also be writing this date to a mysql db, so I'm also wondering what the process is there. If I pass the unformatted date across will it translate internally?
Thanks for any help.
I'm collecting DOB information to allow me to track ages of my users (for restricting access to certain areas - its a writing site that allows uers to submit stories, some of which we would like to prevent from being pushed at young readers) but I am a bit stuck with how to go abut it.
Firstly, I want to collect the DOB in a format more like Nov 10, 1975, as the bulk of our users will be Australian (and hence use dd/mm/yy as opposed to mm/dd/yy) so I thought this format would avoid confusion.
So thats fine, I can use strtotime to convert that to a timestamp and then split that into day month and year for use in calculating their age. But of course, I find out now that the timestamp is unable to hold dates earlier than ... I think its 1970 or so.
So what I'm stuck with is the need to somehow find my own way to convert my date format to day, month, and year manually without using strtotime. But the thing that I did like was the fact that strtotime would convert succesfully even if someone used a different date format. I guess I will have to live without this.
Having said all this, I will also be writing this date to a mysql db, so I'm also wondering what the process is there. If I pass the unformatted date across will it translate internally?
Thanks for any help.