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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:29:21+00:00 2026-06-13T10:29:21+00:00

I have a list of items, each with a date/time option. I need for

  • 0

I have a list of items, each with a date/time option. I need for each list item to have the correct time displayed for it.

But this doesn’t seem to work. It will return the correct ‘am’ or ‘pm’ value for $duedateA, but when I try to set the selected attribute value is gets wonky and will either show the wrong am or pm, or both.

Am I doing something wrong?

if(!empty($resInvoice[0]["due_date"])){
$duedateA = date("a",strtotime($resInvoice[0]['due_date']));
}       
if($duedateA == "am"){
$selected_am = 'selected="selected"';
}
if($duedateA == "pm"){
$selected_pm = 'selected="selected"';
}   

<select name="due_time[a]">
<option value="am" '.$selected_am.'>am</option>
<option value="pm" '.$selected_pm.'>pm</option>
</select>
  • 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-13T10:29:22+00:00Added an answer on June 13, 2026 at 10:29 am
    date_default_timezone_set('America/New_York');
    $resInvoice[0]["due_date"] = '2012-10-26 03:21:44';
    $selected_am = '';
    $selected_pm = '';
    $duedateA = '';
    if(!empty($resInvoice[0]["due_date"])){
        $duedateA = date("a",strtotime($resInvoice[0]["due_date"]));
    }       
    if($duedateA == "am"){
        $selected_am = ' selected="selected"';
    }
    if($duedateA == "pm"){
        $selected_pm = ' selected="selected"';
    }
    
    echo '<select name="due_date[a]">
        <option value="am"'.$selected_am.'>AM</option>
        <option value="pm"'.$selected_pm.'>PM</option>
    </select>';
    

    sorry for all the variables, i have my errors set to strict.

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

Sidebar

Related Questions

I have a list of items, where each item is a simple class containing
I have a list of items. When I create the list each item has
Say I have a list of items from a database. Next to each item
I have here a list of items in a table. Each item has a
I have a list view that displays a collection of items, each item has
I have a list of items and each item has a checkbox attached to
I have a list of items and each item contains a list of sub
I have a generic list of items. Each item contains a DateTime field. I
I have a list view with over 100 items. Each of these items show
Suppose I have a list box with different items, each with unique values, and

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.