/**
  * @since 4.6.x
  */
 public function test_create_new_blank_datetime()
 {
     //if timezone is empty string then the setUp didn't work correctly.  For the purpose of this test
     //we want a high positive timezone, so let's force that if necessary
     if (get_option('timezone_string') != 'Australia/Sydney') {
         update_option('timezone_string', 'Australia/Sydney');
         EEM_Datetime::reset();
         EEM_Datetime::instance();
     }
     EE_Registry::instance()->load_helper('DTT_Helper');
     //make sure now is in the timezone we want to test with.
     $now = new Datetime('@' . (time() + DAY_IN_SECONDS * 30));
     $now->setTimeZone(new DateTimeZone(EEH_DTT_Helper::get_timezone()));
     $now->setTime('8', '0', '0');
     $now->setTimeZone(new DateTimeZone('America/Toronto'));
     //get the default datetime
     $default_date = EEM_Datetime::instance()->create_new_blank_datetime();
     $default_date = reset($default_date);
     //assert instance
     $this->assertInstanceOf('EE_Datetime', $default_date);
     //set its timezone to match our expected timezone
     $default_date->set_timezone('America/Toronto');
     $actual = $default_date->get_DateTime_object('DTT_EVT_start');
     $this->assertInstanceOf('DateTime', $actual);
     //assert timezones are the same
     $this->assertEquals($now->getTimezone(), $actual->getTimeZone());
     //assert that we have the correct values on the date... we'll do each part separately to verify.
     $this->assertEquals($now->format('Y'), $actual->format('Y'));
     $this->assertEquals($now->format('m'), $actual->format('m'));
     $this->assertEquals($now->format('d'), $actual->format('d'));
     $this->assertEquals($now->format('H'), $actual->format('H'));
     $this->assertEquals($now->format('i'), $actual->format('i'));
 }
 static function convert_datetime($timestamp, $to_tz, $from_tz = 'UTC')
 {
     //	Has a specific timestamp been given?
     if (NULL === $timestamp) {
         $timestamp = date('Y-m-d H:i:s');
     } else {
         //	Are we dealing with a UNIX timestamp or a datetime?
         if (!is_numeric($timestamp)) {
             if (!$timestamp || $timestamp == '0000-00-00') {
                 return '';
             }
             $timestamp = date('Y-m-d H:i:s', strtotime($timestamp));
         } else {
             if (!$timestamp) {
                 return '';
             }
             $timestamp = date('Y-m-d H:i:s', $timestamp);
         }
     }
     // --------------------------------------------------------------------------
     //	Perform the conversion
     $_from_tz = new DateTimeZone($from_tz);
     $_out = new Datetime($timestamp, $_from_tz);
     //	Set the output timezone
     $_to_tz = new DateTimeZone($to_tz);
     $_out->setTimeZone($_to_tz);
     return $_out->format('Y-m-d H:i:s');
 }