Code

From XPUB & Lens-Based wiki
Revision as of 01:44, 6 February 2012 by Amy Suo Wu (talk | contribs) (Created page with "code written in php <source lang="php"> <? //-------------- M O D D R ---------------\\ //\ /\ /////// ////\ ////\ ////\ // \/ // // // // // // // // ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

code written in php

<source lang="php">

<? //-------------- M O D D R ---------------\\

 //\  /\   ///////  ////\    ////\    ////\
// \/ //  //   //  //   //  //   //  //   /

// // /////// /////// /////// // \\\

//------------ P R E S E N T S ------------\\ // \ 2012 / \\ // an average guy's average date calculator // // for amy

$text = htmlspecialchars(trim($_POST['input']));//input from the html form below: $textAr = explode("\n", $text);//break input text up by (new)lines: $textAr = array_filter($textAr, 'trim'); // remove any extra \r characters left behind

$linecount = count($textAr); //line count

foreach ($textAr as $line) //for each line... {

   $line2 += strtotime($line); //convert time to unix timestamp and add up

}

echo "average date:

"; echo date("d-F-Y H:i:s", floor($line2/$linecount)); //echo average date echo "


";

//end of php code ?> copy/paste date/time list:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <textarea name="input" rows="20" cols="30"></textarea> <input type="submit" value="submit" name="submit" /> </form>



format:

day-month-year hour:mins:sec
00-00-0000 00:00:00

24hour format (00 - 23) with leading zero



for example:

07-08-1985 17:00:00
17-11-1985 23:35:00
14-02-1984 02:14:00
25-10-1983 00:01:00