Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:56:49+00:00 2026-05-26T17:56:49+00:00

Hi I am trying to create a php calculator which basically does this: $price_m_Fuengirola

  • 0

Hi I am trying to create a php calculator which basically does this:

$price_m_Fuengirola = 11.00;

/* number of people */

$car1 = 0.00; /* 1-4 */
$car2 = 50.00; /* 4-8 */
$car3 = 70.00; /* 8-12 */
$car4 = 90.00; /* 12-16 */

/* Calculator */

date_default_timezone_set('GMT');

//echo $newTime;

echo $price_m_Fuengirola."<br />";

echo $car2."<br />";

function timeCalc(){
$newTime = date("H:i", time());

if ($newTime < "18:56"){

    echo 20.00;
    //echo "<br />this is more time";

} else {

    echo 6.00;
    //echo "this is more time";

}
}


$timeCalc = timeCalc();

echo $timeCalc."<br />";

$total = $price_m_Fuengirola + $car2 + $timeCalc."<br /><br />";

echo $total;`

The logic behind it is if a person orders a taxi before x time then they get charged x else they get charged x (i plan to change it when i manage to get it working), the issue is the price is being added to the car price but not to the function price output. In the function I am trying to only echo a number which isn’t meant to be time so am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:56:49+00:00Added an answer on May 26, 2026 at 5:56 pm

    Here is my particular take:

    <?php
    
    function rateOffset($now, $cutoff){
        if ($now < strtotime($cutoff)){
            return 20.00;
        } else {
            return 6.00;
        }
    }
    
    $cutoff = "18:56";
    
    for ($i = 0; $i < 24; $i++) {
        $now = strtotime("$i:00");
        $rateCalc = rateOffset($now, $cutoff);
        echo date('H:i', $now)." = $rateCalc\n";
    }
    
    ?>
    

    http://ideone.com/owfLg

    Note, I’m comparing two arguments, $now (which is a timestamp), and $cutoff, which is an hh:mm representation of the cutoff time to check. The for loop is to demonstrate the outcomes per hour, which would be:

    00:00 = 20
    01:00 = 20
    02:00 = 20
    03:00 = 20
    04:00 = 20
    05:00 = 20
    06:00 = 20
    07:00 = 20
    08:00 = 20
    09:00 = 20
    10:00 = 20
    11:00 = 20
    12:00 = 20
    13:00 = 20
    14:00 = 20
    15:00 = 20
    16:00 = 20
    17:00 = 20
    18:00 = 20
    19:00 = 6
    20:00 = 6
    21:00 = 6
    22:00 = 6
    23:00 = 6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a BMI calculator. This should allow people to use either
I'm trying to create a PHP file, which wouldn't run if it's already running.
Im trying to create this with the php encode function: { foo: [ {
I'm trying to create a subscription form which basically let's you select a game,
I'm trying to create a php file which I can edit straight away without
I am trying to create a php search engine which can refine search results
I have been trying to create a simple calculator. Using PHP I managed to
I'm trying to create a php page with fopen() this php file will house
I'm currently trying to create a PHP Thrift server which will be accessed by
I am trying to create a php file that adds a user and create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.