SReject commented on a Page, PHP Countup timer for MIRC (start from any date and time)  -  Feb 03, 2013

If im not mistaken you can just use

$duration($abs($calc($ctime(date) - $ctime(date))))
bandbonjtv  -  Feb 03, 2013

thanks sreject, it does work. this is what i used to test your simplified version

on *:text:!sessiontest:#: { describe $chan This Stream Session Went Live $duration($abs($calc($ctime(02/01/2013 14:25:00) - $ctime($date $+ $chr(32) $+ $time)))) } 

BUT..... i would like it to display 1mo, rather then 4wks. if there is a way, im down to learn and ditch this long math problem in my remote section. i included another screenshot for you to see what the result of your snippet looked like side by side the php long conversion snippet.

SReject  -  Feb 04, 2013

$dateDiff:

alias -l durationFix {
  if ($regex(datefix, $1, /^(\d+)wks? (.+)$/i)) {
    var %mo, %wks
    if ($iif($floor($calc($regml(datefix,1) / 4)), $v1,)) {
       var %mo = $v1 $+ mo
       var %wks = $iif($calc($v1 % 4), $v1 $+ wks,)
    }
    return %mo %wks $regml(datefix, 2)
  } 
  return $1
}
alias dateDiff {
  var %diff = $duration($abs($calc($ctime - $ctime($1))))
  return $durationFix(%diff)
}

;usage:
$dateDiff(<date>)

Please note, I did NOT test it. I just went off memory so it could be a bit sketchy :/

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.