DateTime Attribute for Admin->Products

Posted: September 15, 2010 in Magento, Version 1.4.*

Hello Friends …
If you want attribute type as Datetime instead of date Change in following files…
1.lib/Varien/Data/Form/Element/Date.php

Put this line at top of Function

$outputFormat = Mage::app()->getLocale()->getDateTimeFormat( Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);

replace

$displayFormat = Varien_Date::convertZendToStrFtime($outputFormat, true, (bool)$this->getTime());

with this

$displayFormat = Varien_Date::convertZendToStrFtime($outputFormat = Mage::app()->getLocale()->getDateTimeFormat( Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));

And Replace

$this->getTime() ? ‘true’ : ‘false’

With

$this->getTime() ? ‘true’ : ‘true’

Also change in
2.app/code/core/Mage/Core/Model/Locale.php
Find

public function date($date=null, $part=null, $locale=null, $useTimezone=true)

in this function Change this

$date = new Zend_Date($date, $part, $locale);

With this

$date = new Zend_Date($date, “”, $locale);

Thanks
Bijal Bhavsar 🙂

Advertisements
Comments
  1. nacs says:

    hello its not working properly, it saves time but not date is not saved properly as when i choose 28 july, 2011 06:28 and in DB it saved as ” 0011-07-28 06:28:00 ” plz help .
    i am using Magento 1.5.1.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s