I have a really basic question concerning unix timestamp and mysql date. I'm trying to build a small website where users can register and fill in their birthdate.
Problem is that unix starts with Jan 01 1970. Now if i calculate age for users, form dates like date('m.d.Y', $unix_from_db) and so on it will fail with users older that 40 years, right?
So what would be the rigth way for doing this. Sorry, for basic question like this, but I'm inexperienced with php and mysql.
//Edit: Thank you all. I got confused, because, date('m.d.y',mktime(0,0,0,1,1,1890)) and date('m.d.y',-2000) returned 01.01.70 - next time I'll study manual more carefully. I was able to fix my site, thanks again. Too bad I can accept only one answer, they were all equally good.
Unix timestamps for times before 1970 are negative integers, counting the number of seconds until jan 1 1970.
For example, 2/13/1943
is -848343600
So what? Arithmetic works with negative numbers. When they start the epoch makes no difference as long as it's used consistently.
Negative numbers are people too! Don't discriminate! It hurts their feelings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With