hi guys, i have a sql statement in code that returns the max date/time from the records (yyyyddmmhhmm)
my need is to calculate it with time and compare to current date/time and return like 30 mins ago, 20 mins ago… 2 days 11 mins ago…
any hint?
hi guys, i have a sql statement in code that returns the max date/time from the records (yyyyddmmhhmm)
my need is to calculate it with time and compare to current date/time and return like 30 mins ago, 20 mins ago… 2 days 11 mins ago…
any hint?
wounding what the guys are busy with!? nobody tried that!?
i got some functions from php.net but nothing seems to work here
any idea will be great
You have a very powerful database system at your disposal.
SELECT
FLOOR(HOUR(TIMEDIFF(NOW(),(SELECT MAX(date_time_field) FROM your_table))) / 24) AS days,
MOD(HOUR(TIMEDIFF(NOW(),(SELECT MAX(date_time_field) FROM your_table))), 24) AS hours,
MINUTE(TIMEDIFF(NOW(),(SELECT MAX(date_time_field) FROM your_table))) AS minutes
jsb
oh, i am so glad just to read your name dude !:DD I had a feeling you will appear soon though, if you remember, my username was “itsme3” lool
of course I appreciate your input first, actually managed it this afternoon by (interval) function and i could get output like (2 days 2 hours 50 minutes 2 seconds) which is exactly great and what i wanted… i am fighting now to do it something like 28 hrs 32 mins (i want to get rid of “days”) … so still trying, about 60% there next will try to make it bold for example if more than specific time … so reading about date parameters… really interesting, but tough and still confusing for me somehow
again, appreciate your appearance, feeling confident when you are around
cheers
here is what i mean by that dear jsb
$datetime1 = new DateTime([glo_field_date]);
$datetime2 = new DateTime();
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%dd %hh %im');
[glo_new] = $elapsed;
MikeDE - so why did you change your username?
Well his old name was too confusing. Everybody thought it’s him…
nice 1 albert
@adz well, you know bartho for sure, i saw him doing nothing other than “reported to our bugs team” and noticed he is super moderator, so thought to make him do something useful, actually he did after all looooool
by the way guys, what i reached with this code is nice
$datetime1 = new DateTime([glo_field_date]);
$datetime2 = new DateTime();
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%dd %hh %im');
[glo_new] = $elapsed;
i decided to keep it like days, hours, minutes but now trying to format the the output like if more than 10 hours then make it bold… problem that output is not a value that you can put logic (if more than this then do that) i think will try the stackoverflow guys are so active and they’ve been through hell, if you know how to put the code and ask, you get answer in 5 minutes (so many people), if you don’t know how to ask, they will block you loool
cheers
haha albert
haha itsme4 :-p
Well, since you are so enthusiastic about the object style.
Take this.
if($interval->h + ($interval->days*24) > 10)
{
make it bold;
}
jsb
[QUOTE=jsbinca;29506]Well, since you are so enthusiastic about the object style.
Take this.
if($interval->h + ($interval->days*24) > 10)
{
make it bold;
}
jsb[/QUOTE]
thanks boss, appreciated your ongoing valuable support
cheers