Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_weekstartend [ WordPress Function ]

get_weekstartend ( $mysqlstring, $start_of_week = '' )
Parameters:
  • (string) $mysqlstring Date or datetime field type from mysql.
  • (int) $start_of_week Optional. Start of the week as an integer.
Returns:
  • (array) Keys are 'start' and 'end'.
Defined at:



Get the week start and end from the datetime or date string from mysql.

Source


<?php
function get_weekstartend$mysqlstring$start_of_week '' ) {
    
$my substr$mysqlstring0); // Mysql string Year
    
$mm substr$mysqlstring8); // Mysql string Month
    
$md substr$mysqlstring5); // Mysql string day
    
$day mktime000$md$mm$my ); // The timestamp for mysqlstring day.
    
$weekday date'w'$day ); // The day of the week from the timestamp
    
if ( !is_numeric($start_of_week) )
        
$start_of_week get_option'start_of_week' );

    if ( 
$weekday $start_of_week )
        
$weekday += 7;

    
$start $day 86400 * ( $weekday $start_of_week ); // The most recent week start day on or before $day
    
$end $start 604799// $start + 7 days - 1 second
    
return compact'start''end' );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics