- time: documentation ( source)
- date_default_timezone_set: documentation ( source)
- date: documentation ( source)
<?php
date_default_timezone_set('Europe/Warsaw');
$timezoneShift = (2 * 60 * 60); //+2000
$timestamp = time();
$threeHours = (3 * 60 * 60); //3 hours interval
$timezone -= $timezoneShift;
$timestamp += $threeHours;
$reminder = $timestamp % $threeHours;
$timestamp -= $reminder;
$timestamp += $timezoneShift;
echo date('Y-m-d H:i:s', time());
echo date('Y-m-d H:i:s', $timestamp);