im trying to get difference of date/time from a field type datetime
to "right now" using php and mysql as database
this code is working fine, returns the output beautifully ok as
$datetime1 = new DateTime('mydate1');
$datetime2 = new DateTime();
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%d days %h hours %i minutes');
that is ok so far, no issues as this function is for php 5.3 and i
have it on server
my need is 4 small things actually
1) how to eliminate the need for days?
i want to have (25 hours 10 minutes) instead of (1 day 1 hours 10
2) how i can make
$elapsed be bold or colored if the
value is more than 5 hours for example!? simple IF logic will not work
as the output is not actually a predefined value...
3) if the days or hours are 0, then want to remove them!
- For example if showing (0 days 10 hours 40 mins) then no need to
display the (0 days), should show (10 hours 40 mins) that is enough
- Another example: 0 days 0 hours 45 minutes then to show only "45
minutes" no need for days and hours!
4) if output less than 5 minutes in total (0days 0 hours 1-5mins),
then wanna make it show like "a while ago" only no need for any days,
hours or minutes... then after 6 minutes.. go like "6 mins"
shortly something like facebook!?
okay, what i searched tried is different combination of workarounds
but never worked as you know this interval is for php 5.3 and still
seem not widely used?
any hint for one or more parts of this long question is