Php check date-PHP source code

Source: Internet
Author: User
Tags flock php excel gtar
Check date

1. [Code][PHP] code
 
 
 = 0 & $ timeArr [0] <= 23) & ($ timeArr [1]> = 0 & $ timeArr [1] <= 59) & ($ timeArr [2]> = 0 & $ timeArr [2] <= 59) return true; else return false ;} function DateDiff ($ date1, $ date2, $ unit = "") {// Time comparison function, returns the seconds, minutes, hours, or days of difference between two dates switch ($ unit) {case's ': $ pidend = 1; break; case' I ': $ pidend = 60; break; case 'H': $ pidend = 3600; break; case 'D': $ pidend = 86400; break; default: $ pidend = 86400;} $ time1 = strtotime ($ date1); $ time2 = strtotime ($ date2); if ($ time1 & $ time2) return (float) ($ time1-$ time2)/$ pidend; return false ;}?> PHP redirection
 Window. location = "$ PHP_SELF ";"; Method 3: echo"
 ";?> Obtain the visitor's browser
 Obtain the visitor's operating system
 File format
 'Image/GIF', 'jpg '=> 'image/jpeg', 'jpeg '=> 'image/jpeg', 'jpe '=> 'image/jpeg ', 'bmp '=> 'image/bmp', 'PNG '=> 'image/png', 'tif '=> 'image/tiff ', 'Tiff '=> 'image/tiff', 'pict' => 'image/x-pict', 'Pic '=> 'image/x-pict ', 'pct '=> 'image/x-pict', 'tif' => 'image/tiff ', 'Tiff' => 'image/tiff ', 'psd '=> 'image/x-photoshop', 'swf '=> 'application/x-shockwave-Flash ', 'js' => 'application/x-Forwarded Cr limit pt', 'PDF '=> 'AP Plication/pdf ', 'Ps' => 'application/postscr limit pt', 'eps' => 'application/postscr limit pt ', 'AI' => 'application/postscr reject pt', 'WMF '=> 'application/x-msmetafile', 'css' => 'text/css ', 'htm '=> 'text/html', 'html' => 'text/html', 'txt' => 'text/plain ', 'xml' => 'text/XML', 'wml' => 'text/wml', 'wbmp '=> 'image/vnd. wap. wbmp ', 'mid' => 'audio/midi ', 'wav' => 'audio/wav ', 'mp3' => 'audio/mpeg ', 'mp2' => 'audio/mpeg ', 'Av' => 'Video/x-msvideo', 'MPEG '=> 'video/mpeg', 'mpg' => 'video/mpeg ', 'qt '=> 'video/quicktime', 'mov' => 'video/quicktime', 'lha' => 'application/x-lha ', 'lzh '=> 'application/x-lha', 'Z' => 'application/x-compress ', 'gtar' => 'application/x-gtar ', 'gz '=> 'application/x-gzip', 'gzip '=> 'application/x-gzip', 'tgz' => 'application/x-gzip ', 'tar '=> 'application/x-tar', 'bz2' => 'application/bzip2', 'Zip' => 'AP Plication/zip ', 'arj' => 'application/x-arj', 'rar' => 'application/x-rar-compressed ', 'hqx' => 'application/mac-binhex40 ', 'sit' => 'application/x-stuffit ', 'bin' => 'application/x-macbinary ', 'uu '=> 'text/x-uencode', 'uue' => 'text/x-uuencode', 'latex '=> 'application/x-latex ', 'ltx '=> 'application/x-latex', 'tcl '=> 'application/x-tcl', 'pgp '=> 'application/pgp ', 'asc '=> 'application/pgp', 'exe '=> 'app Lication/x-msdownload ', 'Doc' => 'application/msword', 'rtf' => 'application/rtf ', 'XLS' => 'application/vnd. ms-excel ', 'ppt' => 'application/vnd. ms-powerpoint ', 'mdb' => 'application/x-msaccess', 'wri' => 'application/x-mswrite',);?> Php excel file generation
 A simple example of time comparison: for example, a forum uses the new image to mark the posts posted on the day. Method 1:
 Rows [$ I] [date] is the datetime field value in the database. $ today = time (); $ theDay = date ("Y-m-d H: I: s", $ today-24*3600 ); $ newTag = $ db-> rows [$ I] [date]> = $ theDay? "": ""; // Method 2: $ newTag = $ db-> rows [$ I] [date]> = date ("Y-m-d 00:00:00 ")? "": "";?> // Extract the variables submitted by the page and browser, which is equivalent to enabling PHP. INI to enable global variables.
 // Read the file function
 // File writing function
 // Quick page redirection
 NNPage turning ....N "; print"
 N "; print"N "; print"NN "; print"
 
 
  
  
N "; print"
  
  
     N "; print" 
    N "; print" 
   N "; print" 
   
     N "; print" 
    N "; print" 
   N "; print" 
   
     N "; print" 
    N "; print" 
   N "; print" 
  
N "; print" N "; print" N "; print" N "; print" N "; print" N "; print" N "; print" N "; print" N "; print" N "; print" N "; print"N "; print"
Page redirection prompt information
$ Info
N "; print" if your browser does not support automatic jump, click here
N "; print"N"; Exit;?> Generate random string functions Truncate a string of a certain length (this function is valid for GB2312) $ Length) {if ($ sss) {$ length = $ length-3; $ addstr = @#... ;}for ($ I = 0; $ I <$ length; $ I ++) {if (ord ($ string [$ I])> 127) {$ wordscut. = $ string [$ I]. $ string [$ I + 1]; $ I ++;} else {$ wordscut. = $ string [$ I];} return $ wordscut. $ addstr;} return $ string ;}?> Obtain the client IP address Determine email address Paging (use with two functions) ". $ Totalpage ."Page "; $ linkNum = 4; $ start = ($ page-round ($ linkNum/2)> 0? ($ Page-round ($ linkNum/2): "1"; $ end = ($ page + round ($ linkNum/2) <$ totalpage? ($ Page + round ($ linkNum/2): $ totalpage; $ prestart = $ start-1; $ nextend = $ end + 1; if ($ page <> 1) $ out. = "first page"; if ($ start> 1) $ out. = ".. <"; for ($ t = $ start; $ t <= $ end; $ t ++) {$ out. = ($ page = $ t )? "[". $ T."]":" $ T ";} if ($ end <$ totalpage) $ out. = "> .. "; if ($ page <> $ totalpage) $ out. = "Last page"; return $ out;}?> Obtain the ID of the newly inserted data // Obtain the current script URL // Convert the fullwidth number into a halfwidth number // Remove HTML tags ","> ", $ Txt); $ txt = preg_replace ("/[rn] {1,}/isU "," rn ", $ txt ); return $ txt ;}?> // Convert relative paths to absolute paths // Get all links ] *> ([^>] +)/I ', $ code, $ arr); return array ('name' => $ arr [2], 'URL' => $ arr [1]) ;}?> // Convert each line of the HTML table into an array in CSV format ] *?> 'Si ", '"', $ table); $ table = str_replace ("", '",', $ Table); $ table = str_replace (""," {Tr} ", $ table); // remove the HTML tag $ table = preg_replace (" '<[/!] *? [^ <>] *?> 'Si "," ", $ table); // remove the blank character $ table = preg_replace (" '([rn]) [s] + '","", $ table); $ table = str_replace ("", "", $ table); $ table = str_replace ("", "", $ table ); $ table = explode (", {tr}", $ table); array_pop ($ table); return $ table ;}?> // Convert each row and column of an HTML table into an array to collect table data ] *?> 'Si "," ", $ table); $ table = preg_replace ("' ] *?> 'Si "," ", $ table); $ table = preg_replace ("' ] *?> 'Si "," ", $ table); $ table = str_replace (""," {Tr} ", $ table); $ table = str_replace (""," {Td} ", $ table); // remove the HTML tag $ table = preg_replace (" '<[/!] *? [^ <>] *?> 'Si "," ", $ table); // remove the blank character $ table = preg_replace (" '([rn]) [s] + '","", $ table); $ table = str_replace ("", "", $ table); $ table = str_replace ("", "", $ table ); $ table = explode ('{tr}', $ table); array_pop ($ table); foreach ($ table as $ key => $ tr) {$ td = explode ('{td}', $ tr); array_pop ($ td); $ td_array [] = $ td;} return $ td_array;}?> // Return all words in the string $ distinct = true to remove duplicates // Print out a list of people contributing to this PHP project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.