Php obtains the start and end timestamps of today, yesterday, last week, and this month.
// Php obtains the start and end timestamp of today. $ beginToday = mktime (0, 0, date ('M'), date ('D '), date ('Y'); $ endToday = mktime (0, 0, 0, date ('M'), date ('D') + 1, date ('Y ')) -1; echo "start timestamp today :". $ beginToday. '----'. date ('Y-m-d H: I: S', $ beginToday ).'
'; Echo "end time of today:". $ endToday.' ---- '. date ('Y-m-d H: I: S', $ endToday ).'
'; // Php obtains the start timestamp and end timestamp of Yesterday $ beginYesterday = mktime (, 0, date ('M'), date ('D')-1, date ('Y'); $ endYesterday = mktime (0, 0, 0, date ('M'), date ('D'), date ('Y ')) -1; echo "start timestamp yesterday :". $ beginYesterday. '----'. date ('Y-m-d H: I: S', $ beginYesterday ).'
'; Echo "yesterday's end timestamp:". $ endYesterday.' ---- '. date ('Y-m-d H: I: S', $ endYesterday ).'
'; // Php obtains the last week's start timestamp and end timestamp $ beginLastweek = mktime (0, 0, 0, date ('M'), date ('D ') -date ('w') + 1-7, date ('Y'); $ endLastweek = mktime (, 59, 59, date ('M '), date ('D')-date ('w') + 7-7, date ('Y'); echo "last week start timestamp :". $ beginLastweek. '----'. date ('Y-m-d H: I: S', $ beginLastweek ).'
'; Echo "last week end timestamp:". $ endLastweek.' ---- '. date ('Y-m-d H: I: S', $ endLastweek ).'
'; // Php obtains the start timestamp and end timestamp of this month $ beginThismonth = mktime (, 0, date ('M'), 1, date ('Y ')); $ endThismonth = mktime (, 59, 59, date ('M'), date ('t'), date ('Y'); echo "start timestamp of this month :". $ beginThismonth. '----'. date ('Y-m-d H: I: S', $ beginThismonth ).'
'; Echo "end of this month timestamp:". $ endThismonth.' ---- '. date ('Y-m-d H: I: S', $ endThismonth ).'
';