Created
February 18, 2021 10:37
-
-
Save jenswittmann/aa26d9c0b6ddcd81bb0f14f15062c1e1 to your computer and use it in GitHub Desktop.
This MODX Snippet convert german date DD.MM.YYYY to YYYY-MM-DD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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