Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // IMPORTANT: First, make sure you are connecting to the database properly.
- // (Like using mysql_connect() and mysql_select_db())
- $sql_sel="SELECT `dateofbirth`,`Date`,`Month`,`Year` FROM `member_reg`";
- $result=mysql_query($sql_sel); // N.B.: mysql_query() returns a resultset resource
- $row0=mysql_fetch_row($result); // Fetch first row of resultset
- $date1 = $row0["dateofbirth"]; // 1950-01-01
- echo "DEBUG: ".$date1; // Debugging purposes
- $date2 = date("Y-m-d");
- $diff = abs(strtotime($date2) - strtotime($date1));
- $years = floor($diff / (365*60*60*24));
- //$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
- //$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
- printf("%d years\n", $years);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement