Quote from: tkfm at May 25, 2009, 05:10 AM
return date($dateFormat, $status);
I’m not a PHP expert, so this might be wrong idea ...
I think the second parameter of date() function should be UNIX timestamp.
( $status holds character based date like "14-05-2009 12:28:07". )
Nope, you totally have the right idea!! Using information at:
http://bytes.com/groups/php/768105-convert-unix-timestamp I used
$dateFormat = isset($dateFormat)? $dateFormat:’j F Y’;
$tv = "articleDate";
$tvarray = $modx->getTemplateVarOutput($tv);
$date = $tvarray["articleDate"];
$status = strtotime($date);
return date($dateFormat, $status);
to completely solve my problem. I’m also presuming that I had the wrong format for the date for PHx, although I don’t care about that anymore.
Now in the template: [!SiteLastUpdated? &dateFormat=`l jS F Y H:i:s`!] returns Thursday 14th May 2009 12:28:07 from which I might remove the time but its entirely what I was looking for.
To summarise, I can now create a template variable with the date and time of the article (I have some very old articles I may want to put the correct date on) and I can now completely control the output using these parameters (
http://nl3.php.net/date). I did this by changing the Modx Snippet SiteLastUpdated to the above code, which may include at least one line too many, I’m not sure.
According to the above article strtotime($date) (behaves unreliably with dd/mm/(yy)yy dates) which I am not sure is going to be a problem. But I’m very happy with the output. I can’t help feeling that Modx should have this out of the box, but there you go, I learned quite a bit just doing this, hope it might be useful to someone.
Many thanks for the pointers!
Mark