Domanda

Ok, so I have a timer that was written for me that runs a relay. I have it setup so that it runs at 1.1667x faster than a normal speed clock. So it runs like that for however long I need it to.

HOWEVER- The computer crashed and although I know when I started the clock at that rate, I do not know what it would be now, a month later. So I do not know what the time and date would be on in that sped up clock time computer.

What I want to do is write a PHP, Javascript, or other program that I can use to input the start date, the time, and the acceleration multiplier. Then have it tell me what the time and date would be today if I started the clock, say on February 1st at 1.1667x.

Any thoughts on how I might do about doing that? I have some skills in JS, PHP, jQuery. But the mathmatics behind this are completely eluding me.

È stato utile?

Soluzione

php

$startdate = strtotime('2014-02-01 2:20 PM'); 
$rightnow = time();
//get seconds between
$diff = $rightnow - $startdate;
//calc how many seconds should be, 
$timeshouldbe = $diff * 1.1667 + $startdate;
echo date("F j, Y, g:i a", $timeshouldbe);

Altri suggerimenti

That's a very strange application you have there...but the math is quite easy. I'll use JavaScript to demonstrate. First you need the number of milliseconds that have elapsed in real-world time:

var divergence = new Date(2014, 1, 1);  // 0 = Jan, 1 = Feb, etc.

var realElapsed = Date.now() - divergence.getTime();

Then you just apply your multiplier:

var speedyElapsed = realElapsed * 1.1667;

Then construct a date for that:

var speedyDate = new Date(divergence.getTime() + speedyElapsed);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top