Jump to content

iantearle

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

iantearle's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey everyone, been working on this time_since() for a while, basically want it to have the ability to put phrases instead of just time in days, minutes etc, for example if it was less than 30 seconds ago, i would want it to say, "saved a moment ago" here is what i have so far, works great up until weeks! then it just buggers up and doesnt show it weeks, only days! HELP! /* ------------------------------------------------------------ Time Ago Stamp ============================================================ */ function time_since($mbtime){ /* Current unix time */ $now = time(); $diff = $now - $mbtime; /* Convert PHP time/date to legiable data, to do the math */ $today = date('dmy', $now) === date('dmy', $mbtime) ? true : false; if($today && $diff < 10){ // if less than 10 seconds ago $num = ceil($diff / 60); return 'a moment ago'; } elseif($today && $diff < 60){ // if less than a minute ago $num = ceil($diff / 1); return $num . ' second' . ($num > 1 ? 's' : '') . ' ago'; } elseif($today && $diff < 60 * 1){ // if less than 1 minute ago $num = ceil($diff / 60); return 'about a minute ago'; } elseif($today && $diff < 60 * 60){ // if less than an hour ago $num = ceil($diff / 60); return $num . ' minute' . ($num > 1 ? 's' : '') . ' ago'; } elseif($today && $diff < 60 * 60 * 2){ $num = floor($diff / 60 / 60); // if hours ago return 'a couple of hours ago'; } elseif($today && $diff < 60 * 60 * 24){ $num = floor($diff / 60 / 60); // if hours ago return $num . ' hour' . ($num > 1 ? 's' : '') . ' ago'; } elseif($today){ $num = floor($diff / 60 / 60 / 24 / 7); // if hours ago return $num . ' day' . ($num > 1 ? 's' : '') . ' ago'; } else //($today && $diff < 60 * 60 * 24 * 7) { $thisyear = date('y', $now) === date('y', $mbtime) ? true : false; $daydiff = date('z', $now) - date('z', $mbtime); if($daydiff === 1 && $thisyear){ return 'Yesterday'; } $num = ceil($diff / 60 / 60 / 24 / 7); // if Days ago return $num . ' week' . ($num > 1 ? 's' : '') . ' ago'; } return $mbtime; }
  2. Have created the following code to delete a file or folder with a name specified in the form, then submitted with the button, i dont want the action to be carried out on a different page, and this resides within more php functions from 'lussumo filebrowser'. Please help!!!   [code]<div class=\"deletef\"><form name=\"frm".$delete_form_action."\" method=\"get\" action=\"".$this->SelfUrl."\"> <input type=\"text\" size=\"10\" name=\" " .print $folder_name; "\"> <input type=\"submit\" value=\"Delete\"> </form>   </div>         ".$CurrentPath.BuildPath($Config->FolderNavigator, $Config->FilesPerPage)."       </div>"); $delete_form_action = $_SERVER['PHP_SELF']; if (empty($_POST['folder_name'])){ } else { $folder_name = rmdir($_POST['folder_name']); $folder_name = unlink($_POST["foldername"]); }[/code]
  3. I have been trying to work out an argument for ages, but cannot get this to work, I am new to PHP so need anyones help!!! I am sending file and folder names from a form to a script which will delete the matching file or folder the action im using is; <? rmdir($_GET["foldername"]); ?> <? unlink($_GET["foldername"]); ?> where foldername is from the form im submitting. i want to be able to submit the name of either file / folder from the same form, and have the PHP delete either without handing out an error message. Please help, i have tried various ways including function rm($fileglob) but to no avail.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.