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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:25:46+00:00 2026-06-01T02:25:46+00:00

I want to populate a select list such that it increments for each 5

  • 0

I want to populate a select list such that it increments for each 5 minutes starting from 00:00 up til 23:55. I need to do this in UNIX time as well.

Below is what I’ve done but I’ve just realised that doing strtotime("18:00") doesn’t actually give me that hour specifically. I also have a select list of dates, for example a date can be “Tues 6 march 2012” (with the unix format being: 1330992000). I want to be able to take the two selected values and then add the two unix timestamps together so I can insert it into the database. For example, a user selects the time 17:00 which will give me 1332950400 (I know this is wrong) and then the date Tues 6 march 2012 which will give me 1330992000. I want to then be able to add the two timestamps together so I get 18:00 Tues 6 March 2012 in Unix timestamp format.

public function timeSelectList()
{
    //using actual unix time instead of strtotime to save it from having to call the function each time. 
    $startTime = 1332889200; //strtotime('00:00');
    $endTime =  1332975300; //strtotime('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">';
    //populates the select list with the starting date of the course up to the next six months
    while($now <= $endTime)
    {
        if($now == 1332950400)// strtotime('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 == 1332954000)//strtotime('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-01T02:25:48+00:00Added an answer on June 1, 2026 at 2:25 am

    It is a little unclear what the resulting form looks like. Nonetheless, in these situations it is easier to do string math than date math.

    For example, add the date and time together as a string, then determine it’s timestamp.

    $date_string = $date . ' ' . $time; // '2012-03-28 18:00'
    $timestamp = strtotime($date_string);
    

    Note: You’ll of course want to do some validation or string formatting beforehand. But the above should be the final piece you need.

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

Sidebar

Related Questions

<select name="select"> </select> I want to populate the above tag with values from database.
I am trying to create a select list in drupal that is populated from
I have a table layout that I want to populate with the result from
I am trying to populate a select list with time. I want to create
I want to populate a drop down menu with a column from a MySQL
From the admin panel I want to populate a slug field based on a
I want to populate the weeks in a dropdown list when selecting month like
Want to populate dynamically combobox-listbox-drop-down using javascript. var table = document.createElement(table); var select =
I want to populate a List dynamically and display the list when i hover
I want to add a Select One option to a drop down list bound

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.