The following example shows the result:
Copy codeThe Code is as follows:
Array (3) {["yesterday"] => array (2) {[0] => int (1395874800) [1] => int (1395961199 )} ["today"] => array (2) {[0] => int (1395961200) [1] => int (1396047599 )} ["tomorrow"] => array (2) {[0] => int (1396047600) [1] => int (1396133999 )}}
Copy codeThe Code is as follows:
<? Php
// Date Conversion Between Yesterday, Today and Tomorrow
// ($ Startstr start timestamp today)
// Return the values of and (yesterday, today, and tomorrow ).
Function alldaytostr ($ startstr ){
$ Oneday_count = 3600*24; // The number of seconds in a day
// Tomorrow
$ Tomorrow_s = $ startstr + $ oneday_count; // start tomorrow
$ Tomorrow_e = $ tomorrow_s + $ oneday_count-1; // end tomorrow
// Yesterday
$ Yesterday_s = $ startstr-$ oneday_count; // started yesterday
$ Yesterday_e = $ startstr-1; // ended yesterday
// End today
$ Today_e = $ tomorrow_s-1;
// Combine the values of yesterday, today, and tomorrow into an array
$ Allday_array = array ('yesterday' => array ($ yesterday_s, $ yesterday_e ),
'Today' => array ($ startstr, $ today_e ),
'Tomorrow' => array ($ tomorrow_s, $ tomorrow_e ));
Return $ allday_array;
}
// Start time of the current day
$ Btime = date ('Y-m-d'. '00: 00: 00', time ());
// Converts it to the start timestamp.
$ Btimestr = strtotime ($ btime );
Var_dump (alldaytostr ($ btimestr ));
?>