lavary/crunz

Setting timezone dynamically

matiniamirhossein opened this issue · 4 comments

Hi there,
Is there a way to set timezone dynamically in crunz?
We read timezone from a php configuration file.

Thanks.

Hello,

currently you can set it per task using timezone method.
With env vars support (#315) you can set it by env var, but event better will be to support PHP config file where you can do everything you want. WDYT?

@PabloKowalczyk I think its better if we can also do $schedule>timezone() at the beginning of each task file.
Also, thank you for your awesome library, saved me a big time.

@PabloKowalczyk how can I invoice the timezone method?

@vmartinez56 you can specify timezone per task:

<?php

use Crunz\Schedule;

$schedule = new Schedule();
$task = $schedule->run(PHP_BINARY, ['-v']);
$task
    ->everyMinute()
    ->timezone('Europe/Warsaw') // string or \DateTimeZone instance
;