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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:30:47+00:00 2026-05-30T15:30:47+00:00

I’m looking for Zend_Form elements which will allow me to integrate Zend_Date values easily.

  • 0

I’m looking for Zend_Form elements which will allow me to integrate Zend_Date values easily.

For example, I need a hour picker and a week day picker in my forms. for example, the hour picker should display all the hour values from 12:00 AM to 11:00 PM, and the week day picker should display all the available week days.

I was looking for some kind of integration between Zend_Form_Element_Select and Zend_Date, but I couldn’t find any ready to use elements. I would like to use zend_date, so the localization settings I’m already using will be used here.

Ideally, this should be a zend form element that I can set the type of value i need, something like:

    $hour = new Form_Element_DateSelect('hour');
    $hour->setDateFormat(Zend_Date:HOUR);

or

    $weekday = new Form_Element_DateSelect('hour');
    $hour->setDateFormat(Zend_Date:DAYOFWEEK);

I can accomplish it using standard Zend_Form_Element_Select and pre filling the values, however I’m curious if someone made elements for these cases or have an idea to make these elements reusable, and to support multiple date formats.

    $hour = new Zend_Form_Element_Select('hour');
    $hour->setRequired(true)
    ->setLabel('Hour:')
    $this->addElement($hour);

    $time = new Zend_Date();
    $time->setTime('00:00:00');
    for ($i=0;$i<=23;$i++) {
        $hour->addMultiOption($time->get('HH:mm'), $time->toString(Zend_Date::TIME_SHORT));
        $time->addHour(1);
    }
  • 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-30T15:30:48+00:00Added an answer on May 30, 2026 at 3:30 pm

    I’d take a look at Zend_Dojo as this may have some elements close to what you are looking for.

    In particular, dijit.form.TimeTextBox, possibly dijit.Calendar as you can disable weekend dates from being selected, or dijit.form.select which is an extended select box which you could put the weekdays in. Through Zend_Form and Zend_Translate, the weekday names could easily be translated to the language of the user.

    I’m sure plenty of jQuery widgets for doing the same thing would be available. If you went that route, you’d have to do a little bit more work to get it as tightly coupled with Zend_Form as you may want, but you could make your own decorators and elements as well.

    The Zend Framework reference guide has some basic examples on the Dojo form elements TimeTextBox, DateTextBox, and Combo/Select Boxes.

    Maybe using these rich UI elements are even overkill for what you want, if that’s the case, a quick way to do what you want with pre-populating elements would be to make helper methods to return the array of values (weekdays or times) that you can easily feed into Zend_Form_Element_Select::setMultiOptions().

    e.g.

    public function getWeekdays()
    {
        $locale = new Zend_Locale('en_US'); // or get from registry
        $days = Zend_Locale::getTranslationList('Days', $locale);
    
        return $days['format']['wide'];
    }
    
    public function getTimes($options = array())
    {
        $start     = null;  // time to start
        $end       = null;  // time to end
        $increment = 900;   // increment in seconds
        $format    = Zend_Date::TIME_SHORT;  // date/time format
    
        if (is_array($options)) {
            if (isset($options['start']) && $options['start'] instanceof Zend_Date) {
                $start = $options['start'];
            }
            if (isset($options['end']) && $options['end'] instanceof Zend_Date) {
                $end = $options['end'];
            }
            if (isset($options['increment']) && is_int($options['increment']) && (int)$options['increment'] > 0) {
                $increment = (int)$options['increment'];
            }
            if (isset($options['format']) && is_string($options['format'])) {
                $format = $options['format'];
            }
        }
    
        if ($start == null) {
            $start = new Zend_Date('00:00:00', Zend_Date::TIME_LONG);
        }
        if ($end == null) {
            $end   = new Zend_Date('23:59:00', Zend_Date::TIME_LONG);
        }
    
        $times = array();
    
        $time = new Zend_Date($start);
    
        while($time < $end) {  // TODO: check $end > $time
            $times[] = $time->toString($format);
            $time->add($increment, Zend_Date::SECOND);
        }
    
        return $times;
    }
    

    Calling them:

    $opts = array('start' => new Zend_Date('07:00:00', Zend_Date::TIME_LONG),
                  'end'   => new Zend_Date('20:00:00', Zend_Date::TIME_LONG),
                  'increment' => 3600);
    $element->setMultiOptions($form->getTimes($opts));
    
    $element2->setMultiOptions($form->getWeekdays());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters 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.