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 7648367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:41:53+00:00 2026-05-31T10:41:53+00:00

I’m developing a simple sistem so our employees could save their overtime so, at

  • 0

I’m developing a simple sistem so our employees could save their overtime so, at the end of the month, they’re payed for those extra hours they made.

Normal hours are counted as 1 but nightly ones (through 23:00 to 07:00) should be 1,25 hours each.

That said, we’re requesting to introduce the day, and the start and end hours. So, I thought I could have an array like this:

$hours= array(
    '0' => true, '1' => true, '2' => true, '3' => true, '4' => true, '5' => true, '6' => true, 
    '7' => false, '8' => false, '9' => false, '10' => false, '11' => false, '12' => false, '13' => false,
    '14' => false, '15' => false, '16' => false, '17' => false, '18' => false, '19' => false, '20' => false,
    '21' => false, '22' => false,  '23' => true
);

So, basically I test if an hour is special or it isn’t with a loop like this:

$normals = 0;
$specials = 0;
$hour_since = '23:00:00';
$hour_since_expl = explode(':',$hour_since);
$hour_to = '23:15:00';
$hour_to_expl= explode(':',$hour_to );
$date = $fecha = '2012-03-14';
$datetime_since= strtotime($date ." ".$hour_since );
$datetime_to= ((int) $hour_to_expl[0] > (int) $hour_to_expl[0]) ?
        strtotime(date("Y-m-d h:i:s", strtotime($date ." ".$hour_to)) . " +1 day") :
        strtotime($date." ".$hour_to);

$difference = $datetime_to - $datetime_since;
$hours_difference = $difference / SECONDS_PER_HOUR; //60*60
    for ($i = 0; $i <= $difference; $i++){
        $hour = $i + (int) $hour_since_expl [0];
        if ($hours[$hour]) //Special hour here... Pay more!
            $specials++;
        else
            $normals++;
    }

But the problem is when hours are not exact and you have started somewhere like 22:30 and ended 00:30 where you have 0,5 hours being not special. I’ve been struggling my mind but I can’t find any solution.

Do someone have any ideas?

Edit: More code given.

  • 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-31T10:41:54+00:00Added an answer on May 31, 2026 at 10:41 am

    Let’s assume that start time is 15:15 and endtime is 22:45. First, convert start time to nearest HOUR on or after it and endtime to nearest HOUR on or before it. So we get 15:00 and 22:00. Use your loop for these hours and use the differences as follows: if the difference time (15:15-15:00 or 22:45-22:00) is in overtime, then do overtime*numMins/60 else do standard*numMins/60. I’m not familiar with PHP, so had to do this in pseudo code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker

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.