The date format of php processing is seconds ago, minutes ago, hours ago, yesterday, and the day before yesterday. *** modify the date format to different display styles according to the following rules * The number of seconds before Display is less than 1 minute * Less than 1 hour, how many minutes ago * one day, how many hours ago * 3 days ago, display the day before yesterday or yesterday: 12: 23. * If it exceeds 3 days, the complete date is displayed. The php processing date format is seconds ago, minutes ago, hours ago, yesterday, and the day before yesterday.
/*** Modify the date format to different display styles according to the following rules * The number of seconds before the display is less than 1 minute * Less than 1 hour, and the number of minutes before the Display * within one day, how many hours ago * 3 days ago, display the day before yesterday or yesterday: 12: 23. * If it exceeds 3 days, the complete date is displayed. * @ Static * @ param $ sorce_date date unix timestamp * @ return void */public static function getDateStyle ($ sorce_date) {self: $ nowTime = time (); // Obtain the current timestamp // echo 'data source timestamp :'. $ sorce_date. '= '. date ('Y-m-d H: I: S', $ sorce_date); // echo "\ n current timestamp :". date ('Y-m-d H: I: S', self: $ nowTime ). "\ n"; $ timeHtml = ''; // return text format $ temp_time = 0; switch ($ sorce_date) {// One-Minute case ($ sorce_date + 60)> = self: $ nowTime: $ temp_time = self ::$ nowTime-$ sorce_date; $ timeHtml = $ temp_time. "Seconds ago"; break; // hour case ($ sorce_date + 3600)> = self: $ nowTime: $ temp_time = date ('I', self :: $ nowTime-$ sorce_date); $ timeHtml = $ temp_time. "Minute Ago"; break; // day case ($ sorce_date + 3600*24)> = self: $ nowTime: $ temp_time = date ('H', self :: $ nowTime)-date ('H', $ sorce_date); $ timeHtml = $ temp_time. 'hour ago '; break; // yesterday case ($ sorce_date + 3600*24*2)> = self: $ nowTime: $ temp_time = date ('H: I ', $ sorce_date); $ timeHtml = 'Yesterday '. $ temp_time; break; // The day before yesterday case ($ sorce_date + 3600*24*3)> = self: $ nowTime: $ temp_time = date ('H: I ', $ sorce_date); $ timeHtml = 'day before yesterday '. $ temp_time; break; // case 3 days ago ($ sorce_date + 3600*24*4)> = self: $ nowTime: $ timeHtml = '3 days'; break; default: $ timeHtml = date ('Y-m-D', $ sorce_date); break;} return $ timeHtml ;}