CodeIgniter4
CodeIgniter4 copied to clipboard
fix: Time::createFromTimestamp() returns Time with UTC
Description From https://github.com/codeigniter4/shield/pull/1027/files#r1488969384
Time::createFromTimestamp() returns Time with the timezone UTC.
This behavior is misleading.
--- a/app/Config/App.php
+++ b/app/Config/App.php
@@ -109,7 +109,7 @@ class App extends BaseConfig
* @see https://www.php.net/manual/en/timezones.php for list of timezones
* supported by PHP.
*/
- public string $appTimezone = 'UTC';
+ public string $appTimezone = 'Asia/Tokyo';
/**
* --------------------------------------------------------------------------
// UTC 1999-12-31 15:00:00
// Asia/Tokyo 2000-01-01 00:00:00
$timestamp = 946652400;
$time = DatetimeCast::get($timestamp);
return $time->format('Y-m-d H:i:s'); // 1999-12-31 15:00:00
Carbon sets the current timezone.
You can create instances from unix timestamps. createFromTimestamp() create a Carbon instance equal to the given timestamp and will set the timezone as well or default it to the current timezone. https://carbon.nesbot.com/docs/#api-instantiation
Checklist:
- [x] Securely signed commits
- [ ] Component(s) with PHPDoc blocks, only if necessary or adds value
- [ ] Unit testing, with >80% coverage
- [x] User guide updated
- [x] Conforms to style guide
Added docs.