This example describes the PHP custom time conversion function. Share to everyone for your reference, specific as follows:
We can encapsulate functions that are often used in abstract classes and then inherit to use them.
/** * Time stamp * @param object $STR * @return Timestamp/function ToTime ($str, $flag = FA
LSE) {$year = substr ($str, 0, 4);
$month = substr ($str, 5, 2);
$day = substr ($str, 8, 2);
$hour = substr ($str, 11,-3);
$min = substr ($str,-2); if ($flag) {$intTime = Strtotime ($year. '-' . $month. '-' . $day. ' ' . $hour. ':' .
$min); else {$intTime = Strtotime ($year. '-' . $month. '-' .
$day);
}//echo $intTime; exit; return $intTime; int}/** * Timestamp time * @param object $STR * @return/function toDate ($str, $flag = False) {if ($flag) {$dat E_str = Date (' Y ', $str). '-' . Date (' m ', $str). '-' . Date (' d ', $str). ' ' . Date (' H ', $str). ':' .
Date (' I ', $str); else {$date _str = date (' Y ', $str). '-' . Date (' m ', $str). '-' .
Date (' d ', $str);
return $date _str; }
PS: This site also provides a UNIX timestamp conversion tool, including a variety of common language for time stamping operation methods, provided to you for reference:
Unix timestamp (timestamp) conversion tool:
Http://tools.jb51.net/code/unixtime
More about PHP Interested readers can view the site topics: "PHP date and Time usage summary", "PHP Mathematical Calculation Skills Summary", "PHP Array" operation Skills Encyclopedia, "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", " PHP Regular Expression Usage summary, "Summary of PHP operations and operator usage", "PHP string (String) Usage summary" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design.