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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.