• Ok, first of all i dont have any experience in coding but i understand most of it. Anywas, i have this code

    if($minute == 1) { $value = $pre.’One minutes ago’; } else { $value = $pre.$minute.’ minutes’; }

    What I want is to add text before $pre.$minute. to get on my page Some text xx minutes. I tried all sorts of ways and none of them work.

    Any help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • your not doing anything with the variable you are just setting it

    if($minute == 1) {
     echo $pre.'One minutes ago';
    } else {
     echo $pre.$minute.' minutes';
    }
    Thread Starter Daks

    (@daks)

    I want to translate that to my language and on my language prefix is going before minutes. So i want to look like “Ago xx minutes”.

    I dont’ think you have provided enough code…

    your statment says

    $pre = ****

    if Minute is equal to 1 then it will right
    **** One mintues ago

    if not one mintue then it will right

    **** 38 minutes

    Need more information really

    Thread Starter Daks

    (@daks)

    Ok, here’s the whole code

    *****************************************************************/
    function dcf_calculatePastTime($pre, $hour, $minute, $second, $month, $day, $year)
    {
    $old = mktime($hour, $minute, $second, $month, $day, $year);
    $new = mktime();
    $value = $new – $old;

    $second = $value;
    if($second < 0) { $second = 0; }
    $minute = floor($second/60);
    $hour = floor($second/60/60);
    $day = floor($second/60/60/24);
    $month = floor($second/60/60/24/30);
    $year = floor($second/60/60/24/365);

    // check years
    if($year > 0)
    {
    if($year == 1) { $value = $pre.’1 year ago’; } else { $value = $pre.$year.’ years ago’; }
    } else // check months
    if($month > 0)
    {
    if($month == 1) { $value = $pre.’1 month ago’; } else { $value = $pre.$month.’ months ago’; }
    } else // check days
    if($day > 0)
    {
    if($day == 1) { $value = $pre.’1 day ago’; } else { $value = $pre.$day.’ days ago’; }
    } else // check hours
    if($hour > 0)
    {
    if($hour == 1) { $value = $pre.’1 hour ago’; } else { $value = $pre.$hour.’ hours ago’; }
    } else // check minutes
    if($minute > 0)
    {
    if($minute == 1) { $value = $pre.’1 minute ago’; } else { $value = $pre.$minute.’ minutes ago’; }
    } else // check seconds
    if($second >= 0)
    {
    if($second == 0) { $value = ‘Right now’; } else
    if($second == 1) { $value = $pre.’1 second ago’; } else { $value = $pre.$second.’ seconds ago’; }
    }

    return $value;
    }

    Still not sure what is getting passed in throught the $pre variable.

    however you can change the format by moving the words in the ” so you can change it to

    $value = ‘ago’.$pre.$seconds;

    $value = ago 10 seconds

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Need help about code’ is closed to new replies.