Demont Posted November 18, 2008 Share Posted November 18, 2008 I have an RPG I've started programming, a MUD. My question, is how would I go about adding into the database, the age of the user's character based on my custom calendar system I have. Here is the code I have for the custom date. <?php $RealTimeDiff = date("U") - date("U",strtotime("Jan 01, 2008")); $GameTimeDiff = $RealTimeDiff * 4; $GameDate = strtotime("Jan 01, 1980") + $GameTimeDiff; $GameMonth = date("F", $GameDate); $GameYear =abs(date("Y", $GameDate) - 1980 - 450); $BirthYear =abs(date("Y", $GameDate) - 1980 - 433); $Age = $GameYear - $BirthYear; ?> With that, to display the date, I merely have to include the date.php, and print $GameMonth, $GameYear B.C. (as my game is based on The Roman Empire in 450 B.C.) I have, as you can see, the calculation to determine the age, based on the year, but I don't think it would work for every individual who would sign up, as the age would simply calculate the years, based on the current year, and not when that person actually registered. I figured, adding a timestamp of when the person registered, and include the same basic calculation would work, but I'm not sure how to do it. I had someone help me with this simple calculation, as my math skills are atrocious. Any help would be appreciated, and if it helps, here is the code I was going to use for the registration date. $c_hour = date("H"); //Current Hour $c_min = date("i"); //Current Minute $c_sec = date("s"); //Current Second $c_mon = date("m"); //Current Month $c_day = date("d"); //Current Day $c_year = date("Y"); //Current Year $c_timestamp = mktime($c_hour,$c_min,$c_sec,$c_mon,$c_day,$c_year); ... ... $insert = "INSERT INTO users (username,charname,regdate,etc...) VALUES ('".$_POST['username']."','".$_POST['fname']." ".$_POST['lname']."','$c_timestamp')"; $add_member = mysql_query($insert); Link to comment https://forums.phpfreaks.com/topic/133159-custom-calander-helpquestion/ Share on other sites More sharing options...
Demont Posted November 20, 2008 Author Share Posted November 20, 2008 BUMP Link to comment https://forums.phpfreaks.com/topic/133159-custom-calander-helpquestion/#findComment-694763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.