Back to PhocacartDate class

Method getCurrentDate

public static
getCurrentDate
(mixed $minusDays = 0)

Method getCurrentDate - Source code

public static function getCurrentDate($minusDays = 0)
{
    $user = Factory::getUser();
    $config = Factory::getConfig();
    $date = Factory::getDate("NOW", 'UTC');
    $date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
    $date = $date->format('Y-m-d', true, false);
    if ((int) $minusDays > 0) {
        $datePhp = new \DateTime($date);
        $datePhp->sub(new \DateInterval('P' . (int) $minusDays . 'D'));
        $date = $datePhp->format('Y-m-d');
    }
    return $date;
}