get_weekstartend()

get_weekstartend( string $mysqlstring, int|string $star…

get_weekstartend( string $mysqlstring, int|string $start_of_week =  )

从MySQL的datetime或date字符串中获取周的开始和结束。
Get the week start and end from the datetime or date string from MySQL.

目录锚点:#参数#返回#源码


参数(Parameters)

参数 类型 必填 说明
$mysqlstring (string) 必需 MySQL中的日期或日期时间字段类型。
$start_of_week (int | string) 可选 以整数形式开始一周。

返回(Return)

(array)键是“start”和“end”。


源码(Source)

/**
 * Get the week start and end from the datetime or date string from MySQL.
 *
 * @since 0.71
 *
 * @param string     $mysqlstring   Date or datetime field type from MySQL.
 * @param int|string $start_of_week Optional. Start of the week as an integer. Default empty string.
 * @return array Keys are 'start' and 'end'.
 */
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 = date( 'w', $day );

	if ( !is_numeric($start_of_week) )
		$start_of_week = 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="" +="" 7="" days="" -="" 1="" second.="" $end="$start" +="" 7="" *="" day_in_seconds="" -="" 1;="" return="" compact(="" 'start',="" 'end'="" );="" }="">
更新版本 源码位置 使用 被使用
0.71 wp-includes/functions.php:552 1 function 1 function
类别:WordPress 函数手册

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT

登录 账号发表你的看法,还没有账号?立即免费 注册