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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:36:35+00:00 2026-06-01T01:36:35+00:00

I am trying to create two select lists both filled with the same times.

  • 0

I am trying to create two select lists both filled with the same times. It’s basically for the user to select a start time and end time. I’ve calculated these as my times:

$startTime = 0; //00:00
$endTime =  86100; //23:55'
$now = $startTime;

and then I’m incrementing like this:

$now += 300; 

where 300 = 5 minutes, therefore I’m incrementing the time by 5 minutes during each loop.

Therefore, my select lists should look like this:

00:00
00:05
00:10
...
...
23:45
23:50
23:55

The whole thing works, apart from the actual times being printed. I am getting this:

1:00
1:05
...
...
00:45
00:50
00:55

I suspect the problem is the fact we are now in Daylight Saving Time here in the UK. How should I therefore tackle this problem?

This is my actual method:

public function timeSelectList()
{

    $startTime = 0; //00:00
    $endTime =  86100; //23:55'
    $now = $startTime;

    $startSelectList = '<label for="startSelect">Start Time</label><select name="startSelect" id="startSelect">';
    $endSelectList = '<label for="endSelect">End Time</label><select name="endSelect" id="endSelect">';

    while($now <= $endTime)
    {
        if($now == 61200)//17:00
        {
            $startSelectList .= '<option value="'.$now.'" selected="selected">'.date('H:i', $now).'</option>';
            $endSelectList .= '<option value="'.$now.'">'.date('H:i', $now).'</option>';
        }
        else if($now == 64800)//18:00
        {
            $startSelectList .= '<option value="'.$now.'">'.date('H:i', $now).'</option>';
            $endSelectList .= '<option value="'.$now.'" selected="selected">'.date('H:i', $now).'</option>';
        }
        else
        {
            $startSelectList .= '<option value="'.$now.'">'.date('H:i', $now).'</option>';
            $endSelectList .= '<option value="'.$now.'">'.date('H:i', $now).'</option>';
        }
        $now += 300; //increment 5 minutes (300 seconds = 5 minutes
    }

    $startSelectList .= '</select>';
    $endSelectList .= '</select>';

    return $startSelectList.$endSelectList;
}
  • 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-06-01T01:36:37+00:00Added an answer on June 1, 2026 at 1:36 am

    Why not just write a function that will convert seconds into hours/minutes?

    function secToTime($seconds = 0) {
        $hours = floor($seconds/3600);
        $minutes = floor($seconds/60)%60;
        return sprintf('%02d:%02d', $hours, $minutes);
    }
    
    • 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 two functions: get & set, that both accept an arbitrary
I am trying to create two thumbnails of an image uploaded by user. I
I am trying to join two tables like this... SELECT * FROM lists l
I'm trying to create a function that takes two lists and selects an element
I am trying to use PHP and MySQL's Create Table Select between two different
I am trying to UNION two tables with the same fields to create a
I am trying to create two WCF services which should be able to access
I'm trying to create two ASP.NET Membership login pages for an ASP.NET website I'm
I am trying to create two different sets of settings for datepicker( http://keith-wood.name/datepick.html )
I'm trying to create a two-level horizontal navigation menu (or menubar) that displays the

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.