Exemplo n.º 1
0
 function add_datetime_check($var, $var_check, $label, $value, $value_check)
 {
     $id = $this->html_id . '_' . $var;
     $text = '<div class="field">';
     $text .= '<label for="' . $id . '">' . $label . '</label>';
     $text .= '<input class="checkbox" type="checkbox" ' . ($value_check ? ' checked=""' : '') . ' name="is_' . $var . '" onclick="$(\'input[name=' . $var . '_date]\').attr(\'disabled\', !this.checked);$(\'input[name=' . $var . '_time]\').attr(\'disabled\', !this.checked);"/> ';
     $text .= '<input class="string date datepicker" ' . (!$value_check ? ' disabled=""' : '') . ' type="text" name="' . $var . '_date" style="width:80px" value="' . trim(time_format_dateyear($value, true)) . '"/> ';
     $text .= '<input class="string time" ' . (!$value_check ? ' disabled=""' : '') . ' type="text" name="' . $var . '_time" style="width:50px" value="' . time_format_time($value) . '"/>';
     $text .= '</div>';
     return $text;
 }
Exemplo n.º 2
0
function time_format_age($stamp, $is_daily = false)
{
    $current_time = time();
    $age = $current_time - $stamp;
    if ($is_daily) {
        $text = 'Сегодня';
    } else {
        $text = 'Только что';
    }
    if ($age >= 60 && $age < 60 * 60 && !$is_daily) {
        $interval = $age / 60;
        $text = intval($interval) . ' ' . str_format_human_number($interval, array('минуту', 'минуты', 'минут')) . ' назад';
    } elseif ($age >= 60 * 60 && $age < 60 * 60 * 24 && !$is_daily) {
        $interval = $age / (60 * 60);
        $text = intval($interval) . ' ' . str_format_human_number($interval, array('час', 'часа', 'часов')) . ' назад';
    } elseif ($age >= 60 * 60 * 24 && $age < 60 * 60 * 24 * 1) {
        $text = 'вчера ' . time_format_time($stamp);
    } elseif ($age >= 60 * 60 * 24 * 1) {
        $text = time_format_dateyear_human($stamp) . ' ' . time_format_time($stamp);
    }
    return $text;
}