久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔

Drupal: 有起始和結(jié)束時(shí)間,來計(jì)算持續(xù)時(shí)間:修訂間差異

來自站長百科
跳轉(zhuǎn)至: 導(dǎo)航、? 搜索
(新頁面: 此例使用KarenS的'''日期模塊'''來創(chuàng)建兩個(gè)日期字段''field_start_time''和''field_end_time'',它們記錄小時(shí)數(shù)和分鐘數(shù)。接著我們創(chuàng)建一個(gè)計(jì)算型字段...)
?
無編輯摘要
第3行: 第3行:
計(jì)算型字段設(shè)定:
計(jì)算型字段設(shè)定:


*'''Computed Code(計(jì)算代碼):'''
*'''Computed Code,計(jì)算代碼:'''
<pre>
<pre>
$start_date = date_make_date($node->field_start_time[0]['value']);
$start_date = date_make_date($node->field_start_time[0]['value']);
第17行: 第17行:
*'''Display Format,顯示格式''':$display = $node_field_item['value'] . " hours";
*'''Display Format,顯示格式''':$display = $node_field_item['value'] . " hours";


*檢查 'Store using the database settings below
*檢查 'Store using the database settings below'


*'''Data Type,數(shù)據(jù)類型''': float(浮點(diǎn))
*'''Data Type,數(shù)據(jù)類型''': float(浮點(diǎn))

2008年12月8日 (一) 13:58的版本

此例使用KarenS的日期模塊來創(chuàng)建兩個(gè)日期字段field_start_timefield_end_time,它們記錄小時(shí)數(shù)和分鐘數(shù)。接著我們創(chuàng)建一個(gè)計(jì)算型字段來定義持續(xù)時(shí)間--小時(shí)數(shù)--為一類小數(shù)數(shù)字,比如1.5就是1小時(shí),30分鐘。

計(jì)算型字段設(shè)定:

  • Computed Code,計(jì)算代碼:
$start_date = date_make_date($node->field_start_time[0]['value']);
$start = $start_date->db->parts;
$end_date = date_make_date($node->field_end_time[0]['value']);
$end = $end_date->db->parts;
$start_decimal = $start['hours'] + ($start['minutes'] / 60);
$end_decimal = $end['hours'] + ($end['minutes'] / 60);
$node_field[0]['value'] = $end_decimal - $start_decimal;
  • 檢查 'Display this field'
  • Display Format,顯示格式:$display = $node_field_item['value'] . " hours";
  • 檢查 'Store using the database settings below'
  • Data Type,數(shù)據(jù)類型: float(浮點(diǎn))
  • Data Length,數(shù)據(jù)長度: 3,2
  • 檢查 'Sortable'