wpseek.com
				A WordPress-centric search engine for devs and theme authors
			get_weekstartend › WordPress Function
Since0.71
Deprecatedn/a
› get_weekstartend ( $mysqlstring, $start_of_week = '' )
| Parameters: (2) | 
 | 
| Returns: | 
 | 
| Defined at: | 
 | 
| Codex: | 
Gets the week start and end from the datetime or date string from MySQL.
Related Functions: get_post_parent, get_extended, get_last_updated, get_media_states, get_theme_starter_content
	Source
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
	// MySQL string year.
	$my = substr( $mysqlstring, 0, 4 );
	// MySQL string month.
	$mm = substr( $mysqlstring, 8, 2 );
	// MySQL string day.
	$md = substr( $mysqlstring, 5, 2 );
	// The timestamp for MySQL string day.
	$day = mktime( 0, 0, 0, $md, $mm, $my );
	// The day of the week from the timestamp.
	$weekday = (int) gmdate( 'w', $day );
	if ( ! is_numeric( $start_of_week ) ) {
		$start_of_week = (int) get_option( 'start_of_week' );
	}
	if ( $weekday < $start_of_week ) {
		$weekday += 7;
	}
	// The most recent week start day on or before $day.
	$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week );
	// $start + 1 week - 1 second.
	$end = $start + WEEK_IN_SECONDS - 1;
	return compact( 'start', 'end' );
}