InstanceTest.php 804 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /*
  3. * This file is part of the Carbon package.
  4. *
  5. * (c) Brian Nesbitt <brian@nesbot.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Carbon\Carbon;
  11. class InstanceTest extends TestFixture
  12. {
  13. public function testInstanceFromDateTime()
  14. {
  15. $dating = Carbon::instance(\DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11'));
  16. $this->assertCarbon($dating, 1975, 5, 21, 22, 32, 11);
  17. }
  18. public function testInstanceFromDateTimeKeepsTimezoneName()
  19. {
  20. $dating = Carbon::instance(\DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11')->setTimezone(new \DateTimeZone('America/Vancouver')));
  21. $this->assertSame('America/Vancouver', $dating->tzName);
  22. }
  23. }