# adminify/4.1.3/Inc/Classes/Notifications/Base/Date.php

Adminify – White Label, Admin Menu Editor, Login Customizer, version 4.1.3. 141 lines.

- Page: https://pluginprobe.com/plugins/adminify/4.1.3/code/Inc/Classes/Notifications/Base/Date.php
- Raw: https://pluginprobe.com/plugins/adminify/4.1.3/raw/Inc/Classes/Notifications/Base/Date.php
- Modified: 2023-11-01T08:36:22+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/adminify/4.1.3/code/Inc/Classes/Notifications/Base/Date.php#L10-L20`.

```php
<?php
namespace WPAdminify\Inc\Classes\Notifications\Base;

// No, Direct access Sir !!!
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

trait Date {

	/**
	 * Current time
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function current_time() {
		return current_time( 'Y-m-d' );
	}

	/**
	 * Compare dates
	 *
	 * @param [type] $date_1 .
	 * @param [type] $date_2 .
	 * @param [type] $compare .
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_compare( $date_1, $date_2 = null, $compare = null ) {
		if ( ! $compare ) {
			$compare = '==';
		}

		if ( ! $date_2 ) {
			$date_2 = $this->current_time();
		}

		if ( '<' === $compare ) {
			return strtotime( $date_1 ) < strtotime( $date_2 );
		} elseif ( '>' === $compare ) {
			return strtotime( $date_1 ) > strtotime( $date_2 );
		} elseif ( '<=' === $compare ) {
			return strtotime( $date_1 ) <= strtotime( $date_2 );
		} elseif ( '>=' === $compare ) {
			return strtotime( $date_1 ) >= strtotime( $date_2 );
		} else {
			return strtotime( $date_1 ) === strtotime( $date_2 );
		}
	}

	/**
	 * Date Diff
	 *
	 * @param [type] $date_1 .
	 * @param [type] $date_2 .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_diff( $date_1, $date_2 = null ) {
		if ( ! $date_2 ) {
			$date_2 = $this->current_time();
		}
		$diff = date_diff( date_create( $date_2 ), date_create( $date_1 ) );

		return $diff->format( '%R%a' );
	}


	/**
	 * Check Current date
	 *
	 * @param [type] $date_1 .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_is_current( $date_1 ) {
		return $this->date_compare( $date_1 );
	}

	/**
	 * Check Prev date
	 *
	 * @param [type] $date_1 .
	 * @param [type] $date_2 .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_is_prev( $date_1, $date_2 = null ) {
		return $this->date_compare( $date_1, $date_2, '<' );
	}


	/**
	 * Check current or previous date
	 *
	 * @param [type] $date_1 .
	 * @param [type] $date_2 .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_is_current_or_prev( $date_1, $date_2 = null ) {
		return $this->date_compare( $date_1, $date_2, '<=' );
	}


	/**
	 * Date is next day
	 *
	 * @param [type] $date_1 .
	 * @param [type] $date_2 .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_is_next( $date_1, $date_2 = null ) {
		return $this->date_compare( $date_1, $date_2, '>' );
	}

	/**
	 * Current date or next date
	 *
	 * @param [type] $date_1 .
	 * @param [type] $date_2 .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_is_current_or_next( $date_1, $date_2 = null ) {
		return $this->date_compare( $date_1, $date_2, '>=' );
	}


	/**
	 * Date increament
	 *
	 * @param [type] $date .
	 * @param [type] $days .
	 *
	 * @author Jewel Theme <support@jeweltheme.com>
	 */
	public function date_increment( $date, $days ) {
		return gmdate( 'Y-m-d', strtotime( $date . " + $days days" ) );
	}
}
```
