I have torneo_inicio (datetime) and torneo_fin (datetime) fields on my table
then, in phpmaker I did set
torneo_inicio default (‘Y-m-d’,strtotime(‘+7 day’))
torneo_fin default date (‘Y-m-d’,strtotime(‘+120 day’))
both required…
Finally in TableSpecific → Add/Copy → FormCustomValidate I’d put
$rs = $this->GetFieldValues(“FormValue”);
if (CurrentLanguageID() == ‘es’) {
if ($rs[‘torneo_inicio’] <= date (‘d-m-Y’,strtotime(‘+2 day’))){
$customError = "El torneo no puede comenzar antes de ".date (‘d-m-Y’,strtotime(‘+2 day’));
return FALSE;
}
if ($rs[‘torneo_fin’] <= $rs[‘torneo_inicio’]){
$customError = “El torneo no puede finalizar antes de comenzar”;
return FALSE;
}
}
if (CurrentLanguageID() == ‘en’) {
if ($rs[‘torneo_fin’] <= $rs[‘torneo_inicio’]){
$customError = “Tournament can’t finish before start”;
return FALSE;
}
if ($rs[‘torneo_inicio’] <= date (‘Y-m-d’,strtotime(‘+2 day’))){
$customError = "The tournament can’t start before ".date (‘Y-m-d’,strtotime(‘+2 day’));
return FALSE;
}
}
return TRUE;
But it didn’t work well…
$rs[‘torneo_fin’] <= $rs[‘torneo_inicio’] fail
So, how can I compare two dates to validate or not new records?.
in row updating I have similar… but seems working there…
if ($rsold[‘torneo_inicio’] < $rsnew[‘torneo_inicio’]) {
if (CurrentLanguageID() == ‘es’) {
$this->setFailureMessage(“Solo puedes subir la fecha de inicio, no bajarla”);
}
if (CurrentLanguageID() == ‘en’) {
$this->setFailureMessage(“You only can set a higher startdate, not lower”);
}
return FALSE;
}