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

User Access Manager, version 2.3.12. 55 lines.

- Page: https://pluginprobe.com/plugins/user-access-manager/2.3.12/code/src/Util/DateUtil.php
- Raw: https://pluginprobe.com/plugins/user-access-manager/2.3.12/raw/src/Util/DateUtil.php
- Modified: 2026-05-20T16:00:56+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.12/code/src/Util/DateUtil.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace UserAccessManager\Util;

use Exception;
use UserAccessManager\Wrapper\Wordpress;

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

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

    /**
     * @throws Exception
     */
    public function formatDateForDatetimeInput(?string $date): ?string
    {
        return ($date !== null) ? date('Y-m-d\TH:i:s', (int) strtotime($date)) : $date;
    }

    /**
     * @throws Exception
     */
    public function formatDateForDateInput(?string $date): ?string
    {
        return ($date !== null) ? date('Y-m-d', (int) strtotime($date)) : $date;
    }

    /**
     * @throws Exception
     */
    public function formatDateForTimeInput(?string $date): ?string
    {
        return ($date !== null) ? date('H:i:s', (int) strtotime($date)) : $date;
    }

    public function getDateFromTime(?int $time): ?string
    {
        if ($time !== null && $time !== 0) {
            $currentTime = $this->wordpress->currentTime('timestamp');
            return gmdate('Y-m-d H:i:s', $time + $currentTime);
        }

        return null;
    }
}

```
