get_weekstartend()
Get the week start and end from the datetime or date string from MySQL.
1 time — 0.000049 sec (very fast) | 50000 times — 0.33 sec (very fast) | PHP 7.1.2RC1, WP 4.7.3
No Hooks.
Return
Int[]
. Week start and end dates as Unix timestamps.
Usage
get_weekstartend( $mysqlstring, $start_of_week );
- $mysqlstring(string) (required)
- Date or datetime field type from MySQL.
- $start_of_week(int|string)
- Start of the week as an integer.
Default: empty string
Examples
#1 Get the start and end time of a week
Demonstration of the function works.
Let pass into the function the date 3 March 2017
which has a week starting with 27 Feb
and ending with 5 March
:
$arr = get_weekstartend( '2017-03-03' );
As a result, $arr will contain the following array
Array( [start] => 1488153600 // 2017-02-27 00:00:00 - Monday [end] => 1488758399 // 2017-03-05 23:59:59 - Sunday )
Changelog
Since 0.71 | Introduced. |