<?php
/* DateCheck snippet */
$date = $modx->getOption('date', $scriptProperties, '');
if (empty($date)) {
$output = 'Empty Date';
} else {
$dateStamp = strtotime($date);
if ($dateStamp === false) {
$output = 'Date could not be parsed into a timestamp';
} else {
$output = $dateStamp >= time()
? 'YES'
: 'NO'
;
}
}
return $output;
[[!DateCheck? &date=`[[*date]]` ]]
[[!DateCheck? &date=`[[*date]]` &isLower=`YEP` &isGreater=`NOP` ]] how can I do that? hope is clear, Thank you very much!
This question has been answered by Ysanmiguel. See the first response.
[[snippet? &prop1]]
$prop1
<?php
/* DateCheck snippet */
$date = $modx->getOption('date', $scriptProperties, '');
$gt = $modx->getOption('gt', $scriptProperties, 'Greater');
$lt = $modx->getOption('lt', $scriptProperties, 'Lower');
if (empty($date)) {
$output = 'Empty Date';
} else {
$dateStamp = strtotime($date);
if ($dateStamp === false) {
$output = 'Date could not be parsed into a timestamp';
} else {
$output = $dateStamp >= time()
? '$gt'
: '$lt'
;
}
}
return $output;Can you please explain what you're trying to achieve with those new properties?
[[!DateCheck? &date=`[[*date]]` >=`Not available` <=`Still available` ]]
2.
[[!DateCheck? &date=`[[*date]]` >=`[[+listFutureProducts]]` <=`[[+listProducts]]` ]]
$output = $dateStamp >= time() ? '$gt' : '$lt';
$output = $dateStamp >= time() ? $gt : $lt;
$output = $dateStamp >= time() ? '$gt' : '$lt';
has to be
$output = $dateStamp >= time() ? $gt : $lt;
no quotes around $gt and $lt.
<?php
/* DateCheck snippet */
$date = $modx->getOption('date', $scriptProperties, '');
$gt = $modx->getOption('gt', $scriptProperties, 'Greater');
$lt = $modx->getOption('lt', $scriptProperties, 'Lower');
if (empty($date)) {
$output = 'Empty Date';
} else {
$dateStamp = strtotime($date);
if ($dateStamp === false) {
$output = 'Date could not be parsed into a timestamp';
} else {
$output = $dateStamp >= time()
? $gt
: $lt
;
}
}
return $output;[[!DateCheck? &date=`[[*date]]` >=`Greater Than Today` <=`Lower Than Today` ]]