1, compare the size of two dates
Compare the size of two dates, first by converting the date to a timestamp, and then comparing the timestamp.
The sample code is as follows:
<?php$time 1=date ("y-m-d h:i:s");$time 2="2009-12-9 4:40:12";Echo "Time variable \ $time 1 of the time is:".$time 1."\ n";Echo "Time variable \ $time 2 of the time is:".$time 2."\ n";if(Strtotime ($time 1)-strtotime ($time 2) <0){Echo "\ $time 1 before \ $time 2";}Else{Echo "\ $time 2 before \ $time 1";}?>
The results of the operation are as follows:
2, implementation of the page script run time
This is primarily accomplished using the Microtime () function, which returns the current UNIX timestamp and the number of microseconds. Returns a string formatted as msec sec. Where sec is the current Unix timestamp, msec is the number of microseconds.
The syntax format is as follows:
String Microtime (void)
The sample code is as follows:
<?php function run_time(){ List($msec,$sec) =explode (" ", Microtime ());//Use the explode () function to return two variables return((float)$msec+ (float)$sec);//Returns the and of two variables}$start=run_time ();//Run Run_time () function for the first time for($i=0;$i<100000;$i++){}$end=run_time ();//Run the Run_time () function againEcho "Time to run:". ($end-$start)."\ n";?>
Application of time and date of PHP development