Skip to content

Instantly share code, notes, and snippets.

@jenswittmann
Created February 18, 2021 10:37
Show Gist options
  • Save jenswittmann/aa26d9c0b6ddcd81bb0f14f15062c1e1 to your computer and use it in GitHub Desktop.
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
<?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