Monks,
I'm calculating the time when someone logs into a site so I know if they're online or not. It works fine, but one of the guys is in Asia and the time gets inserted ahead of the current time. For example, he logged in on 1/5/2017 at 24:40. There is no such thing as 24:40. He is one day ahead of the US but why would it enter 24:40 no matter when he logged in. It should be the server time. I am stuffing variables of $dateadded2 and $hourmin into the database based on this routine:
sub Calc_Date_Vars {
use DateTime qw( );
$dt = DateTime->now( time_zone => 'Pacific/Honolulu' );
$dateadded_time = $dt->strftime("%l:%M %P");
$dateadded_date = $dt->strftime("%b %e, %Y");
$ymd = $dt->ymd;
$dateadded2 = $ymd;
$hour = $dt->hour_1();
$min = $dt->min();
$hourmin = "$hour:$min";
}
I don't get how a time of 24:40 could be entered at all. Shouldn't 12:40 am be 00:40?
The problem is I calculate the time in minutes (hour x 60 plus minutes) and subtract the last login from now. Then I do this:
if (($lastvisit eq "$dateadded2" && $nowhourmin < 10) {
print "Online";
}
Well, right now the time is 19:42 on 1/5 but his entry says 1/5 24:40. 1/5 was yesterday for him so it's showing him as logged in even if he isn't. Shouldn't the time entered be the server time no matter where you login from? I'm having a brain fart here.