-
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathDateTime.from.phpt
More file actions
29 lines (18 loc) · 1003 Bytes
/
DateTime.from.phpt
File metadata and controls
29 lines (18 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* Test: Nette\Utils\DateTime::from().
*/
declare(strict_types=1);
use Tester\Assert;
use Nette\Utils\DateTime;
require __DIR__ . '/../bootstrap.php';
date_default_timezone_set('Europe/Prague');
Assert::same('1978-01-23 11:40:00', (string) DateTime::from(254400000));
Assert::same('1978-01-23 11:40:00', (string) (new DateTime)->setTimestamp(254400000));
Assert::same(254400000, DateTime::from(254400000)->getTimestamp());
Assert::same('2050-08-13 11:40:00', (string) DateTime::from(2544000000));
Assert::same('2050-08-13 11:40:00', (string) (new DateTime)->setTimestamp(2544000000));
Assert::same(is_int(2544000000) ? 2544000000 : '2544000000', DateTime::from(2544000000)->getTimestamp()); // 64 bit
Assert::same('1978-05-05 00:00:00', (string) DateTime::from('1978-05-05'));
Assert::type(DateTime::class, DateTime::from(new \DateTime('1978-05-05')));
Assert::same('1978-05-05 12:00:00.123450', DateTime::from(new DateTime('1978-05-05 12:00:00.12345'))->format('Y-m-d H:i:s.u'));