Hello guys .. i want to learn some skills in date(); like someone his date birth is 1991/01/01 and today we are 28/02/2008 .. i want to echo 17 years old .. hmm another idea like some members registered today i want to retrieve their data from mysql . i mean last 24H members how ? if anyone can give me the main idea or tell me where can i got this ill be glad Thanks in advance .
You can use datediff function in sql i.e. select DATEDIFF (yyyy, birthdate , today) from mytable. Not sure if it workable on mysql. More info. http://msdn2.microsoft.com/en-us/library/ms186724.aspx
First one: $yr = 1991; $year =date('Y'); $age = $yr - $year; echo $age; Leave it up to you to add checking the month to determine if they are +/-. Second one could use mktime(). Push it back by a day, take the timestamp and compare to the time stamp in the database. $yesterday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y")); $today = mktime(0,0,0); $dif = $today - $yesterday; last two lines are just a double check. A day is 60*60*24 or 86400. Which you could just subtract from mktime(0,0,0); Then use that to compare against the db.