If you are looking into creating a datetime field that does not take into account the timezone so basically you want Jan 15th, 20010 at 5pm no matter what is the daylight saving time is, try the following:
1. Create your field as date using Studio ie: static_date
2. Edit modules/{your module}/vardefs.php and look for static_date
3. Change 'type' => 'varchar', 'len' => '25' and save
4. Edit modules/{your module}/{your module}.php and add the following functions:
Of course replace static_date with your field namePHP Code:function get_list_view_data()
{
global $timedate;
$temp_array = parent::get_list_view_data();
$temp_array['STATIC_DATE'] = $timedate->swap_formats( $temp_array['STATIC_DATE'], $timedate->get_db_date_time_format(), $timedate->get_date_time_format() );
return $temp_array;
}
function fill_in_additional_list_fields()
{
global $timedate;
$this->static_date = $timedate->swap_formats( $this->static_date, $timedate->get_db_date_time_format(), $timedate->get_date_time_format() );
}
function fill_in_additional_detail_fields()
{
global $timedate;
if( !empty( $this->static_date ) ) $this->static_date = $timedate->swap_formats( $this->static_date, $timedate->get_db_date_time_format(), $timedate->get_date_time_format() );
}
function save()
{
global $timedate;
$this->static_date = $timedate->swap_formats( $this->static_date, $timedate->get_date_time_format(), $timedate->get_db_date_time_format() );
parent::save();
}
Save that and you are done. No database change no mess.


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks