# user-access-manager/2.3.20/src/Util/DateUtil.php

User Access Manager, version 2.3.20. 39 lines.

- Page: https://pluginprobe.com/plugins/user-access-manager/2.3.20/code/src/Util/DateUtil.php
- Raw: https://pluginprobe.com/plugins/user-access-manager/2.3.20/raw/src/Util/DateUtil.php
- Modified: 2026-09-10T09:55:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/user-access-manager/2.3.20/code/src/Util/DateUtil.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace UserAccessManager\Util;

use UserAccessManager\Wrapper\Wordpress;

class DateUtil
{
    public function __construct(private Wordpress $wordpress)
    {
    }

    private function formatDateWith(?string $date, string $format): ?string
    {
        return ($date !== null) ? date($format, (int) strtotime($date)) : null;
    }

    public function formatDate(string $date): string
    {
        return $this->wordpress->formatDate($date);
    }

    public function formatDateForDatetimeInput(?string $date): ?string
    {
        return $this->formatDateWith($date, 'Y-m-d\TH:i:s');
    }

    public function getDateFromTime(?int $time): ?string
    {
        if ($time === null || $time === 0) {
            return null;
        }

        return gmdate('Y-m-d H:i:s', $time + $this->wordpress->currentTime('timestamp'));
    }
}

```
