I figure maybe something of interest for the programmers out there. A place where random code can be posted of interest to others. This mainly will be functions, but yeah. Large amounts of code should be placed in spoilers to keep the thread scrolling smaller. Right, so for today's first random code comes from my latest RPG function. Spoiler: PHP Function PHP: function rpgtime($printable=false) { global $bsetting; //default time offset value $timeoffset = 3600 * ($bsetting['defaulttimeoffset'] + 6); //Day 6AM-8PM, Night 8PM-6AM (half day game day cycles) //This will change in the future depending on season! //Time variable! Very important! $microtime = microtime(true); //Seconds in a day: 86400 //Gives us the beginning of the current day's timestamp. $begintoday = mktime(0, 0, 0); //Current seconds spent today. Round to nearest 0.1 $timeday = round($microtime - $begintoday, 1); //We then divide the total seconds in a day by half. //This will allow two cycles in a day. $endtimeday = 86400 / 2; //This variable will generate values 0-43200 [43200 never reached] //The day begins at 12:00AM (0 OR 43200), the day ends at 11:59PM (43199) //This means we need to wrap around if our seconds in a day reaches this. $calrpgtime = ($timeday >= $endtimeday ? $timeday - $endtimeday : $timeday); //Now we need to get our RPG game time. The real value will be twice $calrpgtime. $rpgtime = $calrpgtime * 2; //86399 if ($printable == false) return $rpgtime; //Now to offset this value. For some reason the optimal base offset is 6+yourserver. $rpgtime += $timeoffset; return date("h:i:s A", $rpgtime); } So basically this function allows game day cycles. You can get the date printed off using rpgtime(true), or you can get the exact seconds by just using rpgtime(). Why show it off? Because it is interesting, and thinking of how to divide the current day into two cycles was interesting. Examples: Real time: 08:59:27 PM RPG Time: 05:58:55 PM RPG Timestamp: 64735.6 -- Real time: 09:02:35 PM RPG Time: 06:05:10 PM RPG Timestamp: 65110.0 -- Real time: 09:08:30 PM RPG Time: 06:17:01 PM RPG Timestamp: 65821.6 -- Real time: 09:10:00 PM RPG Time: 06:20:00 PM RPG Timestamp: 66001.0 More examples will be included in a couple of hours. Testing formula at different time to make sure it works throughout. The result is really "every second passes is 2 seconds, each half is a whole second". At least until it reaches the end cycle for that half/end of the day.