There are a couple plugins that read and convert Unix timestamps. They are contained in the time_tools.pl
Code:
###Usage: my $TimeLeft = plugin::GetTimeLeft(UnixTime, ReturnType=0);
# Example: GetTimeLeft(1285623342); # Check current time against a Unix Timestamp and return secs/mins/hours/days/years remaining
# Example: GetTimeLeft(1285623342, "H"); # Check current time against a Unix Timestamp and return hours remaining
# Returns 0 if no time is left
# ReturnType is one of the following: S seconds, M minutes, H hours, D days, Y years
Code:
###Usage: my $EndTime = plugin::GetEndTime("TypeDur", localtime=false);
# Example: GetEndTime("M60"); # Add 60 minutes to the current timestamp and return in unix time
# Example: GetEndTime("H5", 1); # Add 5 hours to the current timestamp and return in readable local time
# TypeDur is set just like as it is for QGlobals
# S | seconds | "S15" = 15 seconds |
# M | minutes | "M30" = 30 minutes |
# H | hours | "H12" = 12 hours |
# D | days | "D90" = 90 days |
# Y | years | "Y5" = 5 years |
# localtime is an optional field
# If set to 1, it will return a readable date/time stamp, otherwise 0 (default) is unix time
You will need to combine these plugins with the DBI module to pull the Unix timestamp from the database.
Here is a sample of how I have it currently used on my server.
Code:
my $myInstance = $dbh->prepare("SELECT * FROM quest_globals WHERE charid = $charID and name like 'Skylance';");
$myInstance->execute();
my @thisInstance = $myInstance->fetchrow_array();
my $hours = plugin::GetTimeLeft($thisInstance[6],"H");
my $minutes = plugin::GetTimeLeft($thisInstance[6],"M");
my $seconds = plugin::GetTimeLeft($thisInstance[6],"S");
my $minLeft = $minutes % 60;
my $secLeft = $seconds % 60;
$instance = ("You are currently bound to this instance for $hours hour(s) $minLeft minutes $secLeft seconds.");