What an interesting puzzle, this is. I stumbled across it and couldn't help but get drawn into solving this.
The best way I can think to tackle this is to work in seconds and then work upwards from there.
So you would start with a particular starting time, where the time corresponds exactly. For this example, let's use 2000-01-01 00:00
Okay, so you need to find the unix epoch (number of seconds since 1970) for 2000-01-01 00:00
The unix epoch is 946684800
Next you will then need to decide the number of seconds that have elapsed since then and multiply them by 4
So 60 seconds later, the unix epoch will be 946684860
In virtual time, this would be 240 seconds later.
$start_epoch = 946684800; /*theoretically this could be in the future if you wanted to start off in the past and work to a synchronised future date, such as 2015-01-01*/
$real_epoch = date("U"); /*current unix epoch*/
$time_ratio = 4; /* ratio - 4 times as fast in this case */
$virtual_epoch = (($real_epoch - $start_epoch) * $time_ratio) + $start_epoch; /* the time within the game */
$virtual_time = date("Y-m-d H:i:s", mktime(0 , 0, $virtual_epoch, 1, 1, 1970)); /* convert the epoch to a real date, using PHP's date() function */ SimonMayer
Junior Poster in Training
53 posts since Apr 2008
Reputation Points: 14
Solved Threads: 10