Easy Date/Time Snippet for MODX Revolution

Usage: [[!now? &format=`%Y` ]]

Parameters:
  • format: the format passed to strftime. If left empty, generates a timestamp.
  • type: A date/time input string that sets which date/time to use. Defaults to 'now'. Can be any string accepted by strtotime.
Snippet code:
$type = $modx->getOption('type',$scriptProperties,'now');
$date = $output = strtotime($type);
$format = $modx->getOption('format',$scriptProperties,'');
if ($format) {
    $output = strftime($format,$date);
}
return $output;