How does PHP generate a timeline from a date? An application example of the date function in PHP. Generate a unix timestamp into a timeline. Through this example, you can master the usage of the date function.
Example, php timeline function code. Copy code Code example: $seconds) { $message = 'just'; } else { $message = $seconds . 'seconds ago'; } } $message = intval ( $seconds / 60 ) . 'Minutes ago'; } $message = idate ( 'H', $nowTime ) - idate ( 'H', $time ) . 'Hours ago'; break; //yesterday case (1 == $days): $message = 'yesterday' . date ( 'H:i', $time ); break; //The day before yesterday case (2 == $days): $message = 'The day before yesterday' . date ( 'H:i', $time ); break; //within 7 days case (7 > $days): $message = $days . 'days ago'; break; //More than 7 days default: $message = date ( 'n month j day H:i', $time ); break; } } return $message; } |