Php timestamp conversion example. The following example shows how to copy the code: array (3) {[yesterday] array (2) {[0] int (1395874800) [1] int (1395961199 )} [today] array (2) {[0] int (1395961200) [The following example shows the result:
The 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 )}}
The code is as follows:
// 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 ));
?>
The usage code is as follows: array (3) {["yesterday"] = array (2) {[0] = int (1395874800) [1] = int (1395961199 )} ["today"] = array (2) {[0] = int (1395961200 )[...