Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This MODX Snippet convert german date DD.MM.YYYY to YYYY-MM-DD
<?php
/**
* dateConvert
*
* DESCRIPTION
*
* This Snippet convert DD.MM.YYYY to YYYY-MM-DD
*
* PROPERTIES:
*
* &input required
* &options required
*
* USAGE:
*
* [[+date:dateConvert=`%Y-%m-%d`]]
*
*/
# vars
$input = $modx->getOption('input', $scriptProperties, false);
# split string
if ($input) {
list($d, $m, $y) = explode('.', $input);
$time = strtotime($y . '-' . $m . '-' . $d);
} else {
$time = time();
}
return strftime($options, $time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment