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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:02:07+00:00 2026-05-23T02:02:07+00:00

I have a form where users select a time from a form <select name=’hour’>

  • 0

I have a form where users select a time from a form

    <select name='hour'>
    <option value='1'>1</option>
    <option value='2'>2</option>
    <option value='3'>3</option>
    <option value='4'>4</option>
    <option value='5'>5</option>
    <option value='6'>6</option>
    <option value='7'>7</option>
    <option value='8'>8</option>
    <option value='9'>9</option>
    <option value='10'>10</option>
    <option value='11'>11</option>
    <option value='12'>12</option>
</select>
:
<select name='min'>
    <option value='00'>00</option>
    <option value='15'>15</option>
    <option value='30'>30</option>
    <option value='45'>45</option>

</select>
<select name='ampm'>
    <option value='AM'>AM</option>
    <option value='PM'>PM</option>
</select>

I’m posting this information to a processing page where I need to save the time that the user submitted in the database in DateTime format. The data will need to be stored in the database in the datetime format (2011-06-11 23:11:07) with the date being today’s date.

I’m thinking that the data function will some how be able to convert it, but I can’t seem to figure it out.

  • 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-23T02:02:08+00:00Added an answer on May 23, 2026 at 2:02 am

    Easy enough. Assuming the user enters 1:09pm, then:

    $hour = intval($_REQUEST['hour']); // 1
    $min = intval($_REQUEST['minute']); // 9
    if (($_REQUEST['ampm'] == 'PM') && ($hour <> 12)) { 
       $hour += 12; // adjust for 24 clock, so $hour becomes 13
    }
    
    $timestring = sprintf('%02d:%02d:00', $hour, $min); // 13:09:00
    $datestring = date('Y-m-d'); // 2011-06-12
    
    $timestamp = $datestring . ' ' . $timestring; // 2011-06-12 13:09:00
    

    There’s other ways of going about this, but this is probably a bit easier to understand.

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

Sidebar

Related Questions

I'm developing an ASP.NET form for data-entry. Users have to select a client from
I am building a form where users must select a time interval, from day
Let's say I have a form where users can search for people whose name
i have a form that has a multiple select drop down. a user can
I have the following multi-select box in a HTML form, where user can select
I have a form which users must fill out and submit. The controller action
I have a form which users can add controls to and when they right
I have a form where users can modify a collection of objects using a
I have a form where users can add input fields with jQuery. <input type="text"
Having trouble with AR 2.3.5, e.g.: users = User.all( :select => u.id, c.user_id, :from

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.