PHP 8.2.31
Preview: TimeUtil.php Size: 1.16 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/src/Utilities/TimeUtil.php

<?php

namespace Automattic\WooCommerce\Utilities;

use \DateTime;
use \DateTimeZone;
use \Exception;

/**
 * Class with date and time utilities.
 */
class TimeUtil {

	/**
	 * Instance of a DateTimeZone object representing UTC.
	 *
	 * @var DateTimeZone
	 */
	private static DateTimeZone $utc_date_time_zone;

	/**
	 * Class constructor.
	 */
	public function __construct() {
		self::$utc_date_time_zone = new DateTimeZone( 'UTC' );
	}

	/**
	 * Get the instance of the DateTimeZone object representing UTC.
	 *
	 * @return DateTimeZone DateTimeZone object representing UTC.
	 */
	public static function get_utc_date_time_zone(): DateTimeZone {
		return self::$utc_date_time_zone;
	}

	/**
	 * Check if a string represents a valid date in a given format.
	 *
	 * @param string $date The date string to check.
	 * @param string $format The format to verify the date string against.
	 * @return bool True if $date represents a valid date/time according to $format, false otherwise.
	 */
	public static function is_valid_date( string $date, string $format = 'Y-m-d H:i:s' ): bool {
		$d = DateTime::createFromFormat( $format, $date );
		return $d && $d->format( $format ) === $date;
	}
}

Directory Contents

Dirs: 0 × Files: 14

Name Size Perms Modified Actions
12.99 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
4.40 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
1.10 KB lrw-r--r-- 2024-05-30 18:23:46
Edit Download
5.19 KB lrw-r--r-- 2026-01-26 10:40:36
Edit Download
1.69 KB lrw-r--r-- 2023-02-22 07:17:34
Edit Download
3.18 KB lrw-r--r-- 2024-08-27 23:04:44
Edit Download
1.87 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
7.11 KB lrw-r--r-- 2025-07-29 12:34:58
Edit Download
9.19 KB lrw-r--r-- 2025-11-24 23:10:10
Edit Download
12.99 KB lrw-r--r-- 2025-10-06 17:56:06
Edit Download
5.01 KB lrw-r--r-- 2025-11-24 23:10:10
Edit Download
1020 B lrw-r--r-- 2025-05-12 21:07:28
Edit Download
5.09 KB lrw-r--r-- 2024-06-04 15:20:30
Edit Download
1.16 KB lrw-r--r-- 2024-01-30 23:24:56
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).