Hi all,
I would like to display some text on my blog page that basically says something like:
3 hours, 24 minutes and 10 seconds since the last post.
Wondering how I would achieve this, wouldn’t be a call from ditto?
Thanks
Lee
Thanks Mark,
I will have a go at that and let you know if I have any success.
Thanks
Lee
Couldn’t find it the downloads, anyone else know the name of the above?
Thanks,
Lee
you need to make you own snippet for this.
There is no think like this yet.
Thanks for your help, i’ll give that a go.
Thanks
Lee
This might get you a little closer to what you were trying to do, although I threw this together quickly, so hopefully it doesn’t have any problems :-D You might want to add some extra conditionals to handle plural so you don’t end up with something like 1 days 1 hours 1 minutes, when you should have 1 day 1 hour 1 minute.
<?php
$table = $modx->getFullTableName("site_content");
$results = $modx->db->select("createdon", $table, "", "createdon DESC", "1");
$results = $modx->db->getRow($results);
$createdon = $results['createdon'];
$now = time();
$diff = $now - $createdon;
$days = floor($diff/60/60/24);
$hours = floor($diff/60/60);
$minutes = floor($diff/60);
if ($days > 0)
{
$output = $days . ' days ';
$diff = $diff - ($days * 86400);
$hours = floor($diff/60/60);
}
if ($hours > 0)
{
$output .= $hours . ' hours';
$diff = $diff - ($hours * 3600);
$minutes = floor($diff/60);
}
if ($minutes >0)
{
$output .= $minutes . ' minutes';
}
return $output;
?>
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.
Lazy...
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.