If you are working with code based deployments instead of using CMS to push out changes, you might have already implemented something similar.
There are 2 approches to implementing this:
1) Define and save date formats
function mymodule_custom_date() { $date_format_monthday = 'm-d'; $format = array(); $format['format'] = $date_format_monthday; $format['type'] = 'custom'; $format['locked'] = 0; $format['is_new'] = 1; date_format_save($format); $format_type = array(); $format_type['title'] = 'month_day'; $format_type['type'] = 'month_day'; $format_type['locked'] = 1; $format_type['is_new'] = 1; date_format_type_save($format_type); variable_set('date_format_'. $format_type['type'], $date_format_monthday); }
2) Implement date format and date type hooks
function example_date_formats() { $date_format_monthday = 'm-d'; $format = array(); $format['format'] = $date_format_monthday; $format['type'] = 'custom'; $format['locked'] = 1; $format['is_new'] = 1; return $format; }
function example_date_format_types() { $format_type = array(); $format_type['title'] = 'month_day'; $format_type['type'] = 'month_day'; $format_type['locked'] = 1; $format_type['is_new'] = 1; return format_type; }
Related blog posts:










1 comment
25th Nov, 11
Thanks so much for this. I used the first method in my install profile and it worked flawlessly.
Post new comment