Google+

Pages

Monday, July 4, 2016

How to add a datetime picker input field in admin module form in magento 1.x

To add a date/time input field in admin form in magento 1.x, you need to simply use code like below:

$dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField(‘time_from’, ‘date’, array(
‘name’ => ‘time_from’,
‘class’ => ‘required-entry’,
‘required’ => true,
‘label’ => Mage::helper(‘event’)->__(‘Time From’),
‘image’ => $this->getSkinUrl(‘images/grid-cal.gif’),
‘input_format’ => Varien_Date::DATETIME_INTERNAL_FORMAT,
‘format’ => $dateFormatIso,
‘time’ => true, //if you don’t want time, then simply set ‘time’ => false,
));

8 comments:

Zinavo-Web Design | Web Development | SEO | Mobile Apps | ERP/CRM said...

It was a good blog and useful. share more updates. Web Design Company Bangalore | Web Design Bangalore

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi

Thank you for your solution. It did not worked for me,
May be you can try solution given at Magento Coders

Visit Us : Magento Ecommerce Development India | Parsys Media

Alex Wood said...

Thanks for sharing the best solution.
Magento Company uk magento Developer uk

Allea John said...

Very informative blog thanks for sharing the information about Magento.

Anonymous said...

Your post has many detail information. magento development company uk I read all your post and I really like it. Thank you for sharing this great post.

Rahul said...

i dont know people always choose www.desss.com for online business building website and hosting @ afffordable price

freya riki said...

Thank you for sharing your info. I really appreciate your efforts and I will be waiting for your next
Mobile app development Company