Skip to content

Instantly share code, notes, and snippets.

@tuanphpvn
Last active August 3, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuanphpvn/907a8876e11c22bf3674 to your computer and use it in GitHub Desktop.
Save tuanphpvn/907a8876e11c22bf3674 to your computer and use it in GitHub Desktop.
Override datetime of Mage_Core_Model_Date #Magento, #Date
<?php
/**
* Features attributes helper
*
* @package timezone
* @author tuanphpvn@gmail.com
*/
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