Date calculations and locales

I have a page that contains a starting and an ending date field. I want to find if the current time falls between those dates. The time() function returns a time that is 3 hours behind the actual time in my country. So, I ended up using the following code, but I was wondering if there is a simpler, more Kirby-like way to do it:

$timezone = 'Europe/Athens';
$now = time();

$starts = new DateTime($page->starts(), new DateTimezone($timezone));
$ends = new DateTime($page->ends(), new DateTimezone($timezone));

$starts_timestamp = $starts->format('U');
$ends_timestamp = $ends->format('U');

if ($now > $starts_t && $now < $ends_t) {

You can set the timezone in your config. If that doesn’t work, set it for once in your index.php.

Then $page->starts()->toDate() etc. should give you a correct timestamp. No need for the DateTime class, I think.

Great, thank you very much!