TimeInterval::next_week_start()public staticWC 1.0

Returns DateTime object representing the next week start, or previous week end if reversed.

The next week start is the first day of the next week at 00:00:00. The previous week end is the last day of the previous week at 23:59:59. The start day is determined by the "start_of_week" wp_option.

Метод класса: TimeInterval{}

Хуков нет.




$result = TimeInterval::next_week_start( $datetime, $reversed );
$datetime(DateTime) (обязательный)
Date and time.
Going backwards in time instead of forward.
По умолчанию: false

Код TimeInterval::next_week_start() WC 8.7.0

public static function next_week_start( $datetime, $reversed = false ) {
	$seven_days = new \DateInterval( 'P7D' );
	// Default timezone set in wp-settings.php.
	$default_timezone = date_default_timezone_get();
	// Timezone that the WP site uses in Settings > General.
	$original_timezone = $datetime->getTimezone();
	// @codingStandardsIgnoreStart
	date_default_timezone_set( 'UTC' );
	$start_end_timestamp  = get_weekstartend( $datetime->format( 'Y-m-d' ) );
	date_default_timezone_set( $default_timezone );
	// @codingStandardsIgnoreEnd
	if ( $reversed ) {
		$result = \DateTime::createFromFormat( 'U', $start_end_timestamp['end'] )->sub( $seven_days );
	} else {
		$result = \DateTime::createFromFormat( 'U', $start_end_timestamp['start'] )->add( $seven_days );
	return \DateTime::createFromFormat( 'Y-m-d H:i:s', $result->format( 'Y-m-d H:i:s' ), $original_timezone );