Hi everyone,
I am trying to create a snippet which calls a date from a template variable, then reformats that date into a different format that is more user friendly.
The snippet pulls the correct data from the TV, because when I print $calstartdate the correct dates show. However, when I use the strtotime, it says that all the dates are 1969-12-31 17:00:00. I’m not sure why this is. Here is the snippet below.
<?php
global $modx;
$rawvalue = $modx->getTemplateVarOutput('CalStartDate');
$calstartdate = "[+CalStartDate+]";
echo date( "Y-m-d H:i:s", strtotime( "$calstartdate" ) );
?>
I’m not quite sure what is going on here - I think it might be an issue with parsing the dates.