Last active
August 3, 2016 14:50
-
-
Save tuanphpvn/907a8876e11c22bf3674 to your computer and use it in GitHub Desktop.
Override datetime of Mage_Core_Model_Date #Magento, #Date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Features attributes helper | |
* | |
* @package timezone | |
* @author [email protected] | |
*/ | |
class BC_Future_Model_Date extends Mage_Core_Model_Date | |
{ | |
protected $timezone; | |
public function __construct($timezone) { | |
$this->timezone = $timezone; | |
parent::__construct(); | |
} | |
/** | |
* Gets the store config timezone | |
* | |
* @return string | |
*/ | |
protected function _getConfigTimezone() | |
{ | |
return $this->timezone; | |
} | |
public function timestamp($input = null) | |
{ | |
if (is_null($input)) { | |
$result = $this->gmtTimestamp(); | |
} else if (is_numeric($input)) { | |
$result = $input; | |
} else { | |
$result = strtotime($input); | |
} | |
$date = new Zend_Date($result); | |
$date->setTimeZone($this->timezone); | |
$timestamp = $date->get(Zend_Date::TIMESTAMP) + $date->get(Zend_Date::TIMEZONE_SECS); | |
unset($date); | |
return $timestamp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment