matthew9090 Posted April 12, 2011 Share Posted April 12, 2011 ive got this so far $difference = strtotime($time_current) - strtotime($time_old); $formula = $production_per_hour / $difference + $current_number; $round = round($formula, 0); so i need to calculate from a timestamp in the database what the new number will be. i just don't know what to divide, times, plus or minus. ive fiddled around with it to see if i could get it right. Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/ Share on other sites More sharing options...
btherl Posted April 12, 2011 Share Posted April 12, 2011 What formula are you trying to implement? Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200397 Share on other sites More sharing options...
matthew9090 Posted April 12, 2011 Author Share Posted April 12, 2011 this one formula = $production_per_hour / $difference + $current_number; it needs to calculate the new value from a timestamp using the difference $difference = strtotime($time_current) - strtotime($time_old); the production per hour and the current value Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200400 Share on other sites More sharing options...
btherl Posted April 12, 2011 Share Posted April 12, 2011 I still don't understand - you have given me a formula in PHP, and you are asking me if it is correct. How can I tell you if it is correct unless you tell me what you are trying to calculate? Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200401 Share on other sites More sharing options...
matthew9090 Posted April 12, 2011 Author Share Posted April 12, 2011 im trying to calculate the new value from a timestamp. there is the current production per hour the current value the time difference from now to the last updated timestamp so depending on the production per hour the number will go up every so often Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200402 Share on other sites More sharing options...
matthew9090 Posted April 12, 2011 Author Share Posted April 12, 2011 so if the production per hour is 60 then that is 1 per minute. so it needs to go up by 1 per minute. and if the production per hour is 120 then that is 2 every minute. i just nned the right formula to work it out. Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200407 Share on other sites More sharing options...
ignace Posted April 12, 2011 Share Posted April 12, 2011 What is the value of $time_current, $time_old and $current_number? var_dump($time_current, $time_old, $current_number); Run this and tell us the output. Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200417 Share on other sites More sharing options...
matthew9090 Posted April 12, 2011 Author Share Posted April 12, 2011 it outputs this: string '2011-04-12 09:25:26' (length=19) string '2011-04-12 09:25:16' (length=19) string '0' (length=1) Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1200428 Share on other sites More sharing options...
sasa Posted April 14, 2011 Share Posted April 14, 2011 $formula = $production_per_hour / 3600 * $difference + $current_number; Quote Link to comment https://forums.phpfreaks.com/topic/233449-which-formula-do-i-use/#findComment-1201558 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.