for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* GpsLab component.
*
* @author Peter Gribanov <[email protected]>
* @copyright Copyright (c) 2016, Peter Gribanov
* @license http://opensource.org/licenses/MIT
*/
namespace GpsLab\Bundle\DateBundle;
class Util
{
* Bugfix for get monday of this week.
* @see https://bugs.php.net/bug.php?id=63740
* @codeCoverageIgnore
* @param \DateTime $date
* @return \DateTime
public static function getMondayThisWeek(\DateTime $date)
$monday = clone $date;
if ($monday->format('N') != 1) {
$monday->modify('Monday this week');
if ($date->format('Y W') != $monday->format('Y W')) {
$monday->modify('-7 day');
}
return $monday;
* @param int $seconds
public static function roundDate(\DateTime $date, $seconds)
$date = clone $date;
return $date->setTimestamp(round($date->getTimestamp() / $seconds) * $seconds);