Skip to content

Instantly share code, notes, and snippets.

@mpchadwick
Created January 4, 2016 15:05
Show Gist options
  • Save mpchadwick/fd789c4f88b9b707f3fb to your computer and use it in GitHub Desktop.
Save mpchadwick/fd789c4f88b9b707f3fb to your computer and use it in GitHub Desktop.
zend-date-issue
<?php
// Replace this with whatever you need to initialize Magento
// this is really only needed to be able to instantiate a `Zend_Date` object
require_once('/var/www/html/app/Mage.php');
Mage::app();
$createdAt = '2016-01-03 05:01:24';
$timezone = 'America/New_York';
$date = new Zend_Date(strtotime($createdAt), null, 'en_US');
$date->setTimezone($timezone);
$date->setHour(0)->setMinute(0)->setSecond(0);
echo $date->get('YYYY-MM-dd') . PHP_EOL;
@mpchadwick
Copy link
Author

Result: 2015-01-03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment