Welcome Guest, Not a member yet? Register   Sign In
How to calculate a product price hourly and days price?
#2

(This post was last modified: 05-09-2021, 04:56 AM by kleber.)

Hi, you have put a lot of code and most of it has nothing to do with the question. But it's ok.

I would convert any unit of time (hour and day) to timestamp and use the smallest unit (hour) to calculate the price.

For example:

https://schoolsofweb.com/how-to-calculat...es-in-php/

PHP Code:
$date1 "2021-05-27 01:00:00";

$date2 "2021-05-28 02:00:00";

$timestamp1 strtotime($date1);

$timestamp2 strtotime($date2);

$hour_diff abs($timestamp2 $timestamp1)/(60*60);

$price_hour 2; 

$final_price 
hour_diff*price_hour
Reply


Messages In This Thread
RE: How to calculate a product price hourly and days price? - by kleber - 05-09-2021, 04:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB