A couple of queries with dates. I am using two editable fields for date input and one of these dates is used as input to publish date:
kfunctions.php:
My first question is how I could check whether, if the 2nd date is entered that it is later than the 1st date - if not - throw an error message. I've looked through tips & tricks and don't think the answer is there.
The second question is about the default_time='@current' - the date and HH default OK to current date/time, BUT MM remains blank. I wonder why? Ideally what I would like is for the date (DD MM YY) to default to current date and for HH and MM to default to 00 and 00. (the reason for this is that much of the time the client will be setting the HH and MM to 00 if they do not want the time element displayed).
- Code: Select all
<cms:editable type='datetime' validator='MyDate::set_default_date' name='date_range_start' format='dmy' allow_time='1' minute_steps='5' default_time='@current' label="Enter single date OR earliest date in range OR first of several dates" desc="set HH:MM to 00:00 if time is not known or you don't want it shown" order='15' />
kfunctions.php:
- Code: Select all
class MyDate{
function set_default_date( $field ){
global $FUNCS;
$date_range_start = trim($field->get_data());
// Set publish_date to value of this field
$f = &$field->siblings[3];
$publish_date = trim( $f->get_data() );
if( $publish_date != '0000-00-00 00:00:00' ){
$date_range_start = $FUNCS->make_date( $date_range_start );
if( $publish_date != $date_range_start ){
$f->store_posted_changes( $date_range_start );
}
}
unset( $f );
return true;
}
}
My first question is how I could check whether, if the 2nd date is entered that it is later than the 1st date - if not - throw an error message. I've looked through tips & tricks and don't think the answer is there.
The second question is about the default_time='@current' - the date and HH default OK to current date/time, BUT MM remains blank. I wonder why? Ideally what I would like is for the date (DD MM YY) to default to current date and for HH and MM to default to 00 and 00. (the reason for this is that much of the time the client will be setting the HH and MM to 00 if they do not want the time element displayed).