yalcin
09-02-2012, 13:18
S.a Kolay gelsin
Diğer bir forumda matematiksel bir işlem için sorduğum soruya "Computed Field modulu bu iş için birebirdir " şeklinde bir yorum yapmıştın
hatta yanlışl hatırlamıyorsam verileri Yüzde'liğini alma işlemi için kullandığını biraz zorlandığını söylemiştin . bu yüzden öncelikle sana sormak istedim
Computed field ile matematiksel işlemleri öğrenmem gerekiyor . Amacım öncelikle iki adet tarih aralıgındaki gün sayısını saydırarak ekrana bastırmak
istiyorum .
ilgili modulun doküman sayfasında
Calculating a duration given a start and end time | drupal.org (http://drupal.org/node/149234) adresini buldum bu adresin başlığı şöyle
"Calculating a duration given a start and end time"
sanırım iki tarih başlama ve bitiş hesaplaması ile ilgili ve birde d7 için örnek bir kod var ben d6 kullancıısyım
d6 için arkadaşın biri bir örnek kod yazmış şöyle ;
Drupal 6 code.
Posted by cannod on June 11, 2009 at 12:41pm
Yes I spent a couple of hours getting it working with D6.
I changed the code a bit to make it more flexible.
Here is the computed code.
NOTE: change "$node->field_datefield" to the field name of your date field.
# Get the values from $node
$start_value = $node->field_datefield[0]['value'];
$end_value = $node->field_datefield[0]['value2'];
$timezone = $node->field_datefield[0]['timezone'];
$type = $node->field_datefield[0]['date_type'];
# Get a date object from the values
$start_date = date_make_date($start_value, $timezone, $type);
$end_date = date_make_date($end_value, $timezone, $type);
# Call the date_difference function to get the difference between the two dates. Note you can specify the duration measure, either years, months, weeks, days, hours, minutes or seconds. I am using hours. The following line is taken from the date_difference function.
# date_difference($date1_in, $date2_in, $measure = 'seconds', $type = DATE_OBJECT)
$duration = date_difference($start_date, $end_date, 'hours');
$node_field[0]['value'] = "$duration";
And the display code.
$display = $node_field_item['value'];
Store in database.
Data type: float
data Length: 5,2
Sortable = checked.
--------------------------------------------------------
Hani ilk defa bir php kodu görüyorum desem yeridir .
Baslangic: Mon, 03/02/2011 - 04:06 ==== field_baslama
bitis: Thu, 02/09/2012 - 11:14 ==== field_bitis
benim yukardaki formatda iki ayrı date fieldim var bunların arasındaki gün sayısını nasıl saydırabilirim ? yukardaki örnek kodu uyguladıgımda
Computed : 0 şeklinde cıkıyor .
Diğer bir forumda matematiksel bir işlem için sorduğum soruya "Computed Field modulu bu iş için birebirdir " şeklinde bir yorum yapmıştın
hatta yanlışl hatırlamıyorsam verileri Yüzde'liğini alma işlemi için kullandığını biraz zorlandığını söylemiştin . bu yüzden öncelikle sana sormak istedim
Computed field ile matematiksel işlemleri öğrenmem gerekiyor . Amacım öncelikle iki adet tarih aralıgındaki gün sayısını saydırarak ekrana bastırmak
istiyorum .
ilgili modulun doküman sayfasında
Calculating a duration given a start and end time | drupal.org (http://drupal.org/node/149234) adresini buldum bu adresin başlığı şöyle
"Calculating a duration given a start and end time"
sanırım iki tarih başlama ve bitiş hesaplaması ile ilgili ve birde d7 için örnek bir kod var ben d6 kullancıısyım
d6 için arkadaşın biri bir örnek kod yazmış şöyle ;
Drupal 6 code.
Posted by cannod on June 11, 2009 at 12:41pm
Yes I spent a couple of hours getting it working with D6.
I changed the code a bit to make it more flexible.
Here is the computed code.
NOTE: change "$node->field_datefield" to the field name of your date field.
# Get the values from $node
$start_value = $node->field_datefield[0]['value'];
$end_value = $node->field_datefield[0]['value2'];
$timezone = $node->field_datefield[0]['timezone'];
$type = $node->field_datefield[0]['date_type'];
# Get a date object from the values
$start_date = date_make_date($start_value, $timezone, $type);
$end_date = date_make_date($end_value, $timezone, $type);
# Call the date_difference function to get the difference between the two dates. Note you can specify the duration measure, either years, months, weeks, days, hours, minutes or seconds. I am using hours. The following line is taken from the date_difference function.
# date_difference($date1_in, $date2_in, $measure = 'seconds', $type = DATE_OBJECT)
$duration = date_difference($start_date, $end_date, 'hours');
$node_field[0]['value'] = "$duration";
And the display code.
$display = $node_field_item['value'];
Store in database.
Data type: float
data Length: 5,2
Sortable = checked.
--------------------------------------------------------
Hani ilk defa bir php kodu görüyorum desem yeridir .
Baslangic: Mon, 03/02/2011 - 04:06 ==== field_baslama
bitis: Thu, 02/09/2012 - 11:14 ==== field_bitis
benim yukardaki formatda iki ayrı date fieldim var bunların arasındaki gün sayısını nasıl saydırabilirim ? yukardaki örnek kodu uyguladıgımda
Computed : 0 şeklinde cıkıyor .