Skip to content

Commit

Permalink
Add IniOverrideConfig::initDefaultTimezoneForCli when using PHP with …
Browse files Browse the repository at this point in the history
…the CLI on Clever

Signed-off-by: Mathieu Ducrot <[email protected]>
  • Loading branch information
mathieu-ducrot committed Mar 26, 2024
1 parent 7cc6fa9 commit b781bd2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
CHANGELOG for 1.x
===================
## v1.2.0 - (2024-03-26)
### Added
- Common Entity Interface and Trait such as the `ProcessInterface` which we will use to monitor cron, api and file generation.
- `ProcessMonitor` to centralize process code management
- `CommandPoolHelper` service to fetch data about the project symfony commands (like getting all cron choices)
- `DateUtils::secondsToString` helper to convert seconds into a small summary string
- `IniOverrideConfig::initDefaultTimezoneForCli` helper to properly set the timezone when using date with PHP CLI on CleverCloud

### Fixed
- `RegexUtils::PHONE_PATTERN` remove wrong extra digit needed on foreign number

## v1.1.0 - (2024-03-25)
### Added
- new `ArrayUtils` methods : `checkIssetKeys`, `trimExplode`, `removeEmpty`, `filterByPattern`, `flatToMap`
Expand Down
11 changes: 11 additions & 0 deletions src/Config/IniOverrideConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,15 @@ public function resetMemoryLimit(): void
{
ini_set('memory_limit', $this->getDefaultMemoryLimit());
}

/**
* Call this function for all PHP script running from the CLI (ex: all symfony cron commands) when you are on CleverCloud to ensure every date
* creation or comparaison are using the right timezone.
* Alternativaly you can also set it directly when invoking the PHP command using the -d option like so :
* php -d date.timezone="Europe/Paris" bin/console app:my-command
*/
public function initDefaultTimezoneForCli(string $timezone = 'Europe/Paris'): void
{
date_default_timezone_set($timezone);
}
}

0 comments on commit b781bd2

Please sign in to comment.